Skip to content

Commit

Permalink
add test case for expired values
Browse files Browse the repository at this point in the history
  • Loading branch information
DCjanus committed Dec 12, 2023
1 parent 97f49b4 commit f0b5e7b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions expirable/expirable_lru_test.go
Expand Up @@ -207,6 +207,20 @@ func TestLRU_Values(t *testing.T) {
}
}

func TestLRU_ValuesWithExpired(t *testing.T) {
lc := NewLRU[string, string](3, nil, time.Millisecond*100)

lc.Add("key1", "val1")
time.Sleep(time.Millisecond * 200) // wait for expiration reaper
lc.Add("key2", "val2")
lc.Add("key3", "val3")

values := lc.Values()
if !reflect.DeepEqual(values, []string{"val2", "val3"}) {
t.Fatalf("values differs from expected")
}
}

// func TestExpirableMultipleClose(_ *testing.T) {
// lc := NewLRU[string, string](10, nil, 0)
// lc.Close()
Expand Down

0 comments on commit f0b5e7b

Please sign in to comment.