imcache icon indicating copy to clipboard operation
imcache copied to clipboard

Fix flaky eviction callback tests

Open erni27 opened this issue 1 year ago • 0 comments

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.

erni27 avatar Feb 21 '24 18:02 erni27