Unexpected method call issue with golang mock unit testing #2106
Answered
by
aldas
SajaiPrathap070
asked this question in
Q&A
|
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. |
Answered by
aldas
Feb 25, 2022
Replies: 1 comment 1 reply
|
I think that the problem is that but mock prepares for one |
1 reply
Answer selected by
SajaiPrathap070
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)