From 19e978da8e951301d6ebdc31d12ffa0bbac7a250 Mon Sep 17 00:00:00 2001 From: Max Malekzadeh Date: Mon, 21 Oct 2024 15:40:21 -0400 Subject: [PATCH] Add more unit tests --- timedmap_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/timedmap_test.go b/timedmap_test.go index 130d0bb..4488c95 100644 --- a/timedmap_test.go +++ b/timedmap_test.go @@ -108,6 +108,18 @@ func TestTimedMapExpiration(t *testing.T) { } } +func TestTimedMapOverride(t *testing.T) { + tm := New[string, int](time.Minute) + tm.Put("key1", 19, 100*time.Millisecond) + time.Sleep(50 * time.Millisecond) + tm.Put("key1", 23, 200*time.Millisecond) + time.Sleep(100 * time.Millisecond) + _, ok := tm.Get("key1") + if !ok { + t.Errorf("expected key1 to still be present") + } +} + func TestTimedMapCleanup(t *testing.T) { tm := New[string, int](200 * time.Millisecond) tm.Put("key", 19, 100*time.Millisecond)