I am trying to use Mockery to mock a Http client, but when I try to pass in the return value I get an error saying type http.Response is not an expression
Below is my interface and handler
type HTTPClient interface { Get(url string) (resp *http.Response, err error) } type Handler struct { httpClient HTTPClient } Mockery generated a mock class which looks like the below
type HTTPClient struct { mock.Mock } // Get provides a mock function with given fields: url func (_m *HTTPClient) Get(url string) (*http.Response, error) { ret := _m.Called(url) var r0 *http.Response if rf, ok := ret.Get(0).(func(string) *http.Response); ok { r0 = rf(url) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(*http.Response) } } var r1 error if rf, ok := ret.Get(1).(func(string) error); ok { r1 = rf(url) } else { r1 = ret.Error(1) } return r0, r1 } In my test, I am trying to mock the httpclient like below
httpClient := &mocks.HTTPClient{} httpClient.On("Get", request.SubscribeURL).Return(resp*http.Response, nil) I am not sure what parameters I am supposed to in Return. What should I be passing?