imcache
imcache copied to clipboard
Fix flaky eviction callback tests
To test the eviction callback functionality the following mock struct is used https://github.com/erni27/imcache/blob/master/imcache_test.go#L1018.
Since the eviction callbacks are invoked in the separate goroutine(s), the assertion methods should wait reasonable amount of time to make sure that the callback has eventually been called / has not been called (e.g. https://github.com/erni27/imcache/blob/master/imcache_test.go#L1029).
Most of the assertion methods though are flaky, e.g. HasNotBeenCalledWith
(https://github.com/erni27/imcache/blob/master/imcache_test.go#L1050) doesn't ensure the callback really has not been called.
Revisit evictionCallbackMock
and improve the flaky assertions. Make sure all tests use the proper assertion methods.