Closed nrxus closed 4 years ago
Calling a mock multiple times can be achieved by either:
FnOnce
and towards FnMut
. This means that any captured data could at most be mutably borrowed and not moved. I am unsure which one of these two approaches is the most limiting to an user.
Another thing to keep in mind, do we want to keep the FnOnce
without clone behavior for the edge cases where the mock needs to move data that cannot be cloned? Or should that just be removed until I come across an scenario that actually needs that kind of mock
Could you add a new method, .always(...)
which had the Clone
constraint?
Yes, that's a possibility.
The biggest two things stopping me from implementing this are:
faux
being pretty new there aren't enough users for me to try and get a feel of what users of faux would want.At some point even without feedback I will move on and just do whatever feels right at the moment but for now I am trying to see if something comes up that guides my decision.
I'd suggest that an active when
mock overrules a standing always
mock.
+1 for multiple calls. Currently cannot switch to faux exclusively because of this.
I am prioritizing this as my next thing to tackle after https://github.com/nrxus/faux/issues/10
fixed in: https://github.com/nrxus/faux/commit/a2fc133fa0a2079feef8a42cc4bbea564a51c0b0
I will close this after doing a new release... which should be soon.
v0.0.4 is released with this feature :tada:
Currently when we set up a mock:
It sets up a one time mock, which means that after the mock is invoked, next time it runs the code will panic saying that no mock was set.
This library should support mocks that are set up once and run multiple times, either a set number of times, or forever.