Skip to content

Commit

Permalink
add TestGetAll
Browse files Browse the repository at this point in the history
  • Loading branch information
knbr13 committed Apr 6, 2024
1 parent dddc72f commit 3ce0617
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions mcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@ func TestGet(t *testing.T) {
}
}

func TestGetAll(t *testing.T) {
cb := New[string, string](3)

db := cb.Build()

db.Set("key1", "value1")
db.Set("key2", "value2")
db.SetWithTimeout("key3", "value3", time.Millisecond)

if m := db.GetAll(); len(m) != 3 {
t.Errorf("GetAll returned unexpected number of keys: %d", len(m))
}

time.Sleep(time.Millisecond * 2)

if m := db.GetAll(); len(m) != 2 {
t.Errorf("GetAll returned unexpected number of keys: %d", len(m))
}
}

func TestGetNonExistentKey(t *testing.T) {
db := newManual[string, string](&CacheBuilder[string, string]{
size: 10,
Expand Down

0 comments on commit 3ce0617

Please sign in to comment.