Skip to content

Commit cb90d4c

Browse files
committed
add test to check zero expiry
1 parent 2601bb0 commit cb90d4c

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

cache_internal_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,30 @@ func TestDeleteExpired(t *testing.T) {
143143
t.Errorf("want %d items but got %d", want, got)
144144
}
145145
})
146+
147+
t.Run("issue #64", func(t *testing.T) {
148+
defer restore()
149+
c := New[string, int]()
150+
c.Set("1", 4, WithExpiration(0)) // These should not be expired
151+
c.Set("2", 5, WithExpiration(-1)) // These should not be expired
152+
c.Set("3", 6, WithExpiration(1*time.Hour))
153+
154+
want := true
155+
_, ok := c.Get("1")
156+
if ok != want {
157+
t.Errorf("want %t but got %t", want, ok)
158+
}
159+
160+
_, ok = c.Get("2")
161+
if ok != want {
162+
t.Errorf("want %t but got %t", want, ok)
163+
}
164+
_, ok = c.Get("3")
165+
if ok != want {
166+
t.Errorf("want %t but got %t", want, ok)
167+
}
168+
169+
})
146170
}
147171

148172
func max(x, y int) int {

0 commit comments

Comments
 (0)