Unexpected method call issue with golang mock unit testing #2106
-
Hello, Since Iam new, I dont know how to fix the unexpected method call error. Please check the below code and help me in fixing this issue. This is my struct:
This is my service interface:
This is my Unit test:
And this is my error result.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think that the problem is that but mock prepares for one |
Beta Was this translation helpful? Give feedback.
I think that the problem is that
UpdateMainCategory(mainCategoryID string, mainCategory mongodb.MainCategory) (int64, error)
takes 2 argumentsbut mock prepares for one
database.On("UpdateMainCategory", tc.dBWhen).Return(tc.dBReturn, tc.dBError)