-
Notifications
You must be signed in to change notification settings - Fork 64
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
Why mock with no expectations not failing #12
Comments
All expected commands have been executed. |
ok, but shouldnt it fail, or, it would be nice to set it up to fail if a command is executed that should not be executed. In my case i want to ensure nothing is written to redis in certain cases. is there a way to set that up? |
You will receive the error returned by the command. // fail
err = redisCli.Set(context.TODO(), "key", "value", 0).Err()
Expect(err).NotTo(HaveOccurred()) |
ah. thats how it is intended. Unfortunately that doesnt solve my case. the method im testing is handling the error (and not returning it), so i wont be able to assert that Set was never called. i like the behaviour of testify (https://github.com/stretchr/testify). it panics when an unexpected method is called, causing the test to fail. Would be nice to be have a toggle that panics instead of returning an error |
Running into the same issue. It's quite confusing that the mock does not fail on unexpected method calls. |
Can we add a function for reporting unexpected command calls into the Here is my proposal Pull Request: #91 |
This package looks awesome, but i would have expected these tests to fail:
Im calling a
Set
that is not expected, why is that not failing?The text was updated successfully, but these errors were encountered: