-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
mock: Call.NotBefore still expects calls removed with Call.Unset #1542
Comments
This happens because in Unset, the Call removes itself from its parent Mock's ExpectedCalls. It can't do that to other Call instances which expect it because they are allowed between different Mock instances. Perhaps we could make the Call mark itself satisfied as well or instead? Or would that break other public methods that the Call has? |
I think the cleanest way to handle this would be to have an additional field in the This new field should be checked in the
I would prefer the first option because unsetting a call that is required elsewhere sounds like a misconfigured test setup to me. What do you think? |
I think Unset should not exist, it doesn't align with the good practice of testing for state. But it is part of our promise now. On the approach, I think the cleanest way would be for the call being Unset to mark itself as "satisfied" somehow, but we can't becuse that is done by checking that the Parent's Argument matching in |
I'm still not convinced that the cleanest approach would be to mark the call as satisfied. Faking something that didn't actually happen to satisfy the Unset logic sounds more like a workaround to me, since it abuses the logic of the expected calls, and could lead to unexpected behaviours, as you also pointed out. That's why I was proposing to add a reference to the "dependent" calls in the |
Okay, I think I would approve that fix in v1 if you want to make a pull request. I'd still then like to refactor this to something simpler in v2 when we can unexport some of the internals. |
Yes I'd be happy to do it! Can you assign it to me? |
Description
If you remove a call from a mock with Unset, then NotBefore still expects it.
Step To Reproduce
Expected behaviour
Test passes
Actual behaviour
The text was updated successfully, but these errors were encountered: