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 default behaviour when Times() is not specified.
Also, I understand that we can specify the order of calls using InOrder() or After() but if I am not using any of these methods and have multiple calls of the same func like above then what would be the default behaviour in that case ?
The issue I am getting is I see that when update is called both the times the second return value of update is being used. I expected it to at least use nil once and then error other time even if the order is random. Can anyone please help me in understanding why this behaviour is occuring.
Some more context around my testcase: I am testing a function called TestA and what would happen when let say TestA runs parallly so I have started two go routines to call TestA and the above mentioned mocks