test(decaymap): fix tests

Signed-off-by: Xe Iaso <me@xeiaso.net>
This commit is contained in:
Xe Iaso
2025-12-28 18:46:32 -05:00
parent f56c242167
commit f2cde94b71
4 changed files with 11 additions and 27 deletions

View File

@@ -30,15 +30,7 @@ func TestImpl(t *testing.T) {
t.Error("got value even though it was supposed to be expired")
}
// Deletion of expired entries after Get is deferred to a background worker.
// Assert it eventually disappears from the map.
deadline := time.Now().Add(200 * time.Millisecond)
for time.Now().Before(deadline) {
if dm.Len() == 0 {
break
}
time.Sleep(5 * time.Millisecond)
}
dm.Cleanup()
if dm.Len() != 0 {
t.Fatalf("expected background cleanup to remove expired key; len=%d", dm.Len())
}