Mocking func argument using gomock
I want to mock function which takes func argument.
Mocking same function without using Times() in goLang
mockClient.EXPECT().Get(gomock.Any()).Return(res1) mockClient.EXPECT().List(gomock.Any()).Return(res2, nil) mockClient.EXPECT().Create(gomock.Any()).Return(nil) mockClient.EXPECT().Update(gomock.Any()).Return(nil) mockClient.EXPECT().List(gomock.Any()).Return(nil, nil) mockClient.EXPECT().Done(gomock.Any()).Return(nil, nil) mockClient.EXPECT().Get(gomock.Any()).Return(res1) mockClient.EXPECT().List(gomock.Any()).Return(res2, nil) mockClient.EXPECT().Update(gomock.Any()).Return(errors.New(“failed to update”)) mockClient.EXPECT().Create(gomock.Any()).Return(nil) mockClient.EXPECT().List(gomock.Any()).DoAndReturn(func(){ time.Sleep(2*time.Second) return res3} ) This is a simplfied flow of calls that I am making to test a function. I have not used the Times() metohod for nay of these calls. I want to understand what is the […]