diff --git a/.gitignore b/.gitignore index c4468d2..00348ab 100644 --- a/.gitignore +++ b/.gitignore @@ -20,8 +20,5 @@ # Go workspace file # go.work -# Generated mocks -mocks/ - # Coverage file coverage.xml \ No newline at end of file diff --git a/pkg/resty/mocks/mock_Client.go b/pkg/resty/mocks/mock_Client.go new file mode 100644 index 0000000..337178e --- /dev/null +++ b/pkg/resty/mocks/mock_Client.go @@ -0,0 +1,149 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package mocks + +import mock "github.com/stretchr/testify/mock" + +// MockClient is an autogenerated mock type for the Client type +type MockClient struct { + mock.Mock +} + +type MockClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockClient) EXPECT() *MockClient_Expecter { + return &MockClient_Expecter{mock: &_m.Mock} +} + +// Get provides a mock function with given fields: uri +func (_m *MockClient) Get(uri string) ([]byte, error) { + ret := _m.Called(uri) + + if len(ret) == 0 { + panic("no return value specified for Get") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]byte, error)); ok { + return rf(uri) + } + if rf, ok := ret.Get(0).(func(string) []byte); ok { + r0 = rf(uri) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(uri) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClient_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get' +type MockClient_Get_Call struct { + *mock.Call +} + +// Get is a helper method to define mock.On call +// - uri string +func (_e *MockClient_Expecter) Get(uri interface{}) *MockClient_Get_Call { + return &MockClient_Get_Call{Call: _e.mock.On("Get", uri)} +} + +func (_c *MockClient_Get_Call) Run(run func(uri string)) *MockClient_Get_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *MockClient_Get_Call) Return(_a0 []byte, _a1 error) *MockClient_Get_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClient_Get_Call) RunAndReturn(run func(string) ([]byte, error)) *MockClient_Get_Call { + _c.Call.Return(run) + return _c +} + +// Post provides a mock function with given fields: uri, body +func (_m *MockClient) Post(uri string, body interface{}) ([]byte, error) { + ret := _m.Called(uri, body) + + if len(ret) == 0 { + panic("no return value specified for Post") + } + + var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(string, interface{}) ([]byte, error)); ok { + return rf(uri, body) + } + if rf, ok := ret.Get(0).(func(string, interface{}) []byte); ok { + r0 = rf(uri, body) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]byte) + } + } + + if rf, ok := ret.Get(1).(func(string, interface{}) error); ok { + r1 = rf(uri, body) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockClient_Post_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Post' +type MockClient_Post_Call struct { + *mock.Call +} + +// Post is a helper method to define mock.On call +// - uri string +// - body interface{} +func (_e *MockClient_Expecter) Post(uri interface{}, body interface{}) *MockClient_Post_Call { + return &MockClient_Post_Call{Call: _e.mock.On("Post", uri, body)} +} + +func (_c *MockClient_Post_Call) Run(run func(uri string, body interface{})) *MockClient_Post_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(interface{})) + }) + return _c +} + +func (_c *MockClient_Post_Call) Return(_a0 []byte, _a1 error) *MockClient_Post_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockClient_Post_Call) RunAndReturn(run func(string, interface{}) ([]byte, error)) *MockClient_Post_Call { + _c.Call.Return(run) + return _c +} + +// NewMockClient creates a new instance of MockClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockClient { + mock := &MockClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/pkg/resty/mocks/mock_HttpClient.go b/pkg/resty/mocks/mock_HttpClient.go new file mode 100644 index 0000000..4c2da0d --- /dev/null +++ b/pkg/resty/mocks/mock_HttpClient.go @@ -0,0 +1,94 @@ +// Code generated by mockery v2.42.0. DO NOT EDIT. + +package mocks + +import ( + http "net/http" + + mock "github.com/stretchr/testify/mock" +) + +// MockHttpClient is an autogenerated mock type for the HttpClient type +type MockHttpClient struct { + mock.Mock +} + +type MockHttpClient_Expecter struct { + mock *mock.Mock +} + +func (_m *MockHttpClient) EXPECT() *MockHttpClient_Expecter { + return &MockHttpClient_Expecter{mock: &_m.Mock} +} + +// Do provides a mock function with given fields: _a0 +func (_m *MockHttpClient) Do(_a0 *http.Request) (*http.Response, error) { + ret := _m.Called(_a0) + + if len(ret) == 0 { + panic("no return value specified for Do") + } + + var r0 *http.Response + var r1 error + if rf, ok := ret.Get(0).(func(*http.Request) (*http.Response, error)); ok { + return rf(_a0) + } + if rf, ok := ret.Get(0).(func(*http.Request) *http.Response); ok { + r0 = rf(_a0) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*http.Response) + } + } + + if rf, ok := ret.Get(1).(func(*http.Request) error); ok { + r1 = rf(_a0) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHttpClient_Do_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Do' +type MockHttpClient_Do_Call struct { + *mock.Call +} + +// Do is a helper method to define mock.On call +// - _a0 *http.Request +func (_e *MockHttpClient_Expecter) Do(_a0 interface{}) *MockHttpClient_Do_Call { + return &MockHttpClient_Do_Call{Call: _e.mock.On("Do", _a0)} +} + +func (_c *MockHttpClient_Do_Call) Run(run func(_a0 *http.Request)) *MockHttpClient_Do_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(*http.Request)) + }) + return _c +} + +func (_c *MockHttpClient_Do_Call) Return(_a0 *http.Response, _a1 error) *MockHttpClient_Do_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHttpClient_Do_Call) RunAndReturn(run func(*http.Request) (*http.Response, error)) *MockHttpClient_Do_Call { + _c.Call.Return(run) + return _c +} + +// NewMockHttpClient creates a new instance of MockHttpClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockHttpClient(t interface { + mock.TestingT + Cleanup(func()) +}) *MockHttpClient { + mock := &MockHttpClient{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +}