You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 27, 2023. It is now read-only.
I am trying to mock out a GroupCache(source at https://github.com/golang/groupcache) instance for testing and I am running into issues with the Get() call. GroupCache's Get function returns an error object but places the result of the Get into the third argument, dest, which is of type groupcache.Sink. Is there a way to mock a mutation of an argument in a function using gomock? I have tried using both Do and SetArg but I have been unable to produce the result I am looking for. This is a simplified example of what I am trying to do:
type GroupCache interface {
Get(ctx groupcache.Context, key string, dest groupcache.Sink) error
}
...
func TestGroupCacheMock(t *testing.T){
ctrl := gomock.NewController(t)
mockGroupCache := NewMockGroupCache(ctrl)
mockGroupCache.EXPECT().Get(gomock.Any()).Return(nil).AnyTimes() // This line is where I am unsure of what to do.
...
}
So in this example I want the mocked call to Get from my mocked GroupCache to return nil and set the dest variable to some arbitrary value.