Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected result of argument matcher if no args expected but args supplied #292

Closed
IvoGoman opened this issue Jul 14, 2022 · 3 comments · Fixed by #295
Closed

Unexpected result of argument matcher if no args expected but args supplied #292

IvoGoman opened this issue Jul 14, 2022 · 3 comments · Fixed by #295

Comments

@IvoGoman
Copy link
Contributor

Issue

Query is created dynamically in the code. Sometimes it will expect an arg and sometimes it won't.
I expected that the mock would raise an error if the expectation is no query args but actually one is supplied.

Reproduction steps

https://go.dev/play/p/VwF9k6KlET2

Expected Result

Unexpected error ... arguments do not match: expected 0, but got 1 arguments

Actual Result

No error, expectations are met

Locally I have fixed this by removing:

if nil == e.args {
return nil
}

I expected that the mock should catch if an unexpected argument is passed. Be it on the mock or on the actual query in the productive code.

@IvoGoman
Copy link
Contributor Author

If you feel like this is valid, then I am willing to open a PR with the mentioned fix. I saw some tests will need to be fixed.

@fatelei
Copy link
Collaborator

fatelei commented Jul 30, 2022

If you feel like this is valid, then I am willing to open a PR with the mentioned fix. I saw some tests will need to be fixed.

do it, wait for you pr

@IvoGoman
Copy link
Contributor Author

@fatelei could you have a look at #295

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants