testify icon indicating copy to clipboard operation
testify copied to clipboard

mock - get call count/list in thread safe way

Open nbaztec opened this issue 4 years ago • 1 comments

What Currently retrieving the calls via mock.Calls results in a data race condition when the test is using multiple go routines.

Expected A thread-safe way to obtain the call count/list.

Use Case A poller object uses a mocked client that is called in an infinite polling loop until a private flag is set on the poller object to exit it. Testing that upon setting the private flag, the infinite loop is no longer invoking the mocked client's method. This would be trivial to do if we'd have access to the call-count after the flag is set, and if the call count stays the same after 1 second.

nbaztec avatar Jun 15 '20 19:06 nbaztec

See: https://github.com/AtakamaLLC/tsmock

earonesty avatar Jan 11 '22 18:01 earonesty