From 7709bfbcc576e927d4e78a0e928de5c76c65da3f Mon Sep 17 00:00:00 2001 From: Udeep Tandukar Date: Tue, 18 Sep 2018 10:49:49 -0600 Subject: [PATCH] Add mocks to interfaces Co-authored-by: Stephanie Melnyk --- README.md | 5 +- mock_AttachmentInterface.go | 105 ++++++++++++++++++++++++++ mock_Interface.go | 144 ++++++++++++++++++++++++++++++++++++ 3 files changed, 253 insertions(+), 1 deletion(-) create mode 100644 mock_AttachmentInterface.go create mode 100644 mock_Interface.go diff --git a/README.md b/README.md index 0ae8f4c..cd2ea1a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # VSlack - Go -### Version 1.2.0 +### Version 1.3.0 Send messages to slack using a slack incoming web hook in Go. ## Examples @@ -67,6 +67,9 @@ func attach() { ## Change Log +### 1.3.0 +- Add mocks to Interface and AttachmentInterface + ### 1.2.0 - Fix name in Interface of `SetIncomingWebhookURI` diff --git a/mock_AttachmentInterface.go b/mock_AttachmentInterface.go new file mode 100644 index 0000000..d1d9c41 --- /dev/null +++ b/mock_AttachmentInterface.go @@ -0,0 +1,105 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. +package vslack + +import mock "github.com/stretchr/testify/mock" + +// MockAttachmentInterface is an autogenerated mock type for the AttachmentInterface type +type MockAttachmentInterface struct { + mock.Mock +} + +// SetColor provides a mock function with given fields: c +func (_m *MockAttachmentInterface) SetColor(c string) Attachment { + ret := _m.Called(c) + + var r0 Attachment + if rf, ok := ret.Get(0).(func(string) Attachment); ok { + r0 = rf(c) + } else { + r0 = ret.Get(0).(Attachment) + } + + return r0 +} + +// SetFields provides a mock function with given fields: f +func (_m *MockAttachmentInterface) SetFields(f ...Field) Attachment { + _va := make([]interface{}, len(f)) + for _i := range f { + _va[_i] = f[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 Attachment + if rf, ok := ret.Get(0).(func(...Field) Attachment); ok { + r0 = rf(f...) + } else { + r0 = ret.Get(0).(Attachment) + } + + return r0 +} + +// SetMarkdown provides a mock function with given fields: m +func (_m *MockAttachmentInterface) SetMarkdown(m bool) Attachment { + ret := _m.Called(m) + + var r0 Attachment + if rf, ok := ret.Get(0).(func(bool) Attachment); ok { + r0 = rf(m) + } else { + r0 = ret.Get(0).(Attachment) + } + + return r0 +} + +// SetMarkdownIn provides a mock function with given fields: opts +func (_m *MockAttachmentInterface) SetMarkdownIn(opts ...MarkdownOption) Attachment { + _va := make([]interface{}, len(opts)) + for _i := range opts { + _va[_i] = opts[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 Attachment + if rf, ok := ret.Get(0).(func(...MarkdownOption) Attachment); ok { + r0 = rf(opts...) + } else { + r0 = ret.Get(0).(Attachment) + } + + return r0 +} + +// SetText provides a mock function with given fields: t +func (_m *MockAttachmentInterface) SetText(t string) Attachment { + ret := _m.Called(t) + + var r0 Attachment + if rf, ok := ret.Get(0).(func(string) Attachment); ok { + r0 = rf(t) + } else { + r0 = ret.Get(0).(Attachment) + } + + return r0 +} + +// SetTitle provides a mock function with given fields: t +func (_m *MockAttachmentInterface) SetTitle(t string) Attachment { + ret := _m.Called(t) + + var r0 Attachment + if rf, ok := ret.Get(0).(func(string) Attachment); ok { + r0 = rf(t) + } else { + r0 = ret.Get(0).(Attachment) + } + + return r0 +} diff --git a/mock_Interface.go b/mock_Interface.go new file mode 100644 index 0000000..58d7764 --- /dev/null +++ b/mock_Interface.go @@ -0,0 +1,144 @@ +// Code generated by mockery v1.0.0. DO NOT EDIT. +package vslack + +import mock "github.com/stretchr/testify/mock" + +// MockInterface is an autogenerated mock type for the Interface type +type MockInterface struct { + mock.Mock +} + +// validate provides a mock function with given fields: +func (_m *MockInterface) validate() error { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Send provides a mock function with given fields: +func (_m *MockInterface) Send() error { + ret := _m.Called() + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// SendAsync provides a mock function with given fields: e +func (_m *MockInterface) SendAsync(e chan error) { + _m.Called(e) +} + +// SetAttachments provides a mock function with given fields: a +func (_m *MockInterface) SetAttachments(a ...Attachment) *VSlack { + _va := make([]interface{}, len(a)) + for _i := range a { + _va[_i] = a[_i] + } + var _ca []interface{} + _ca = append(_ca, _va...) + ret := _m.Called(_ca...) + + var r0 *VSlack + if rf, ok := ret.Get(0).(func(...Attachment) *VSlack); ok { + r0 = rf(a...) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*VSlack) + } + } + + return r0 +} + +// SetChannel provides a mock function with given fields: c +func (_m *MockInterface) SetChannel(c string) *VSlack { + ret := _m.Called(c) + + var r0 *VSlack + if rf, ok := ret.Get(0).(func(string) *VSlack); ok { + r0 = rf(c) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*VSlack) + } + } + + return r0 +} + +// SetIconEmoji provides a mock function with given fields: i +func (_m *MockInterface) SetIconEmoji(i string) *VSlack { + ret := _m.Called(i) + + var r0 *VSlack + if rf, ok := ret.Get(0).(func(string) *VSlack); ok { + r0 = rf(i) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*VSlack) + } + } + + return r0 +} + +// SetIncomingWebhookURI provides a mock function with given fields: h +func (_m *MockInterface) SetIncomingWebhookURI(h string) *VSlack { + ret := _m.Called(h) + + var r0 *VSlack + if rf, ok := ret.Get(0).(func(string) *VSlack); ok { + r0 = rf(h) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*VSlack) + } + } + + return r0 +} + +// SetMessage provides a mock function with given fields: m +func (_m *MockInterface) SetMessage(m string) *VSlack { + ret := _m.Called(m) + + var r0 *VSlack + if rf, ok := ret.Get(0).(func(string) *VSlack); ok { + r0 = rf(m) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*VSlack) + } + } + + return r0 +} + +// SetUsername provides a mock function with given fields: u +func (_m *MockInterface) SetUsername(u string) *VSlack { + ret := _m.Called(u) + + var r0 *VSlack + if rf, ok := ret.Get(0).(func(string) *VSlack); ok { + r0 = rf(u) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*VSlack) + } + } + + return r0 +}