From e855196fb67b36c4115548b286426a2319593221 Mon Sep 17 00:00:00 2001 From: FZambia Date: Mon, 20 Nov 2023 19:45:17 +0200 Subject: [PATCH] fix race in test --- broker_memory_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/broker_memory_test.go b/broker_memory_test.go index 16645fdd..6a4e41a4 100644 --- a/broker_memory_test.go +++ b/broker_memory_test.go @@ -126,9 +126,13 @@ func TestMemoryBrokerResultCacheExpires(t *testing.T) { }) require.NoError(t, err) + e.resultCacheMu.Lock() require.Len(t, e.resultCache, 1) + e.resultCacheMu.Unlock() time.Sleep(2 * time.Second) + e.resultCacheMu.Lock() require.Len(t, e.resultCache, 0) + e.resultCacheMu.Unlock() } func TestMemoryBrokerPublishIdempotent(t *testing.T) {