Open henrikrudstrom opened 3 years ago
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 mock.PanicOnUnexpectedCall(true)
or somthing. Happy to provide a PR for that. (i guess its a matter of adding an if statement around here: https://github.com/go-redis/redismock/blob/master/mock.go#L153)
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 Expect
interface?
Here is my proposal Pull Request: https://github.com/go-redis/redismock/pull/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?