I originally created this issue in February 2022 in the golang/mock repository. But as this project has been abandoned in favour of this fork I will suggest the feature over here too.
I want to be able to check whether all expected calls have been made before Controller#Finish() gets invoked as the code being tested is running asynchronously and I can only approximate when all calls will have been made.
This addition should allow it to check whether all expected calls towards the mock(s) have been made in an idempotent way.
This is useful when testing asynchronous/non-deterministic things that aren't fully under the developers control (e.g., in end-2-end tests).
If necessary I can elaborate on my specific testing scenario.
Having such a method allows the user to write something like
require.Eventually(t, mockCtrl.AllExpectedCallsSatisfied, 60time.Second, 100time.Millisecond)
instead of having to wait for an approximated amount of time (which slows down the tests unnecessarily) in order to make sure all expected calls have been satisfied before Controller#Finish() gets invoked.
Why is this needed? Because right now AFAIU I have to add a sleep for an amount of time I approximate to be enough for my system to be done with its work. This is not nice for several reasons:
It's dangerous (and a bad idea in general) because my estimation could be too little and calls have not been made at that point
It's slow because I basically have to approximate very conservatively due to the problem described above.
I already created an MR in golang/mock (golang/mock#627), which I could easily recreate over here.
I originally created this issue in February 2022 in the
golang/mock
repository. But as this project has been abandoned in favour of this fork I will suggest the feature over here too.I want to be able to check whether all expected calls have been made before Controller#Finish() gets invoked as the code being tested is running asynchronously and I can only approximate when all calls will have been made.
This addition should allow it to check whether all expected calls towards the mock(s) have been made in an idempotent way. This is useful when testing asynchronous/non-deterministic things that aren't fully under the developers control (e.g., in end-2-end tests).
If necessary I can elaborate on my specific testing scenario.
Having such a method allows the user to write something like
require.Eventually(t, mockCtrl.AllExpectedCallsSatisfied, 60time.Second, 100time.Millisecond) instead of having to wait for an approximated amount of time (which slows down the tests unnecessarily) in order to make sure all expected calls have been satisfied before Controller#Finish() gets invoked.
Why is this needed? Because right now AFAIU I have to add a sleep for an amount of time I approximate to be enough for my system to be done with its work. This is not nice for several reasons:
It's dangerous (and a bad idea in general) because my estimation could be too little and calls have not been made at that point It's slow because I basically have to approximate very conservatively due to the problem described above.
I already created an MR in
golang/mock
(golang/mock#627), which I could easily recreate over here.