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)