Skip to content

Commit 6298b34

Browse files
committed
fix tests
1 parent 62b62f2 commit 6298b34

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cache_internal_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ import (
99
func TestDeletedCache(t *testing.T) {
1010
ctx, cancel := context.WithCancel(context.Background())
1111
defer cancel()
12+
restore := func() {
13+
nowFunc = time.Now
14+
}
15+
defer restore()
1216

1317
nc := NewContext[string, int](ctx)
1418
key := "key"
15-
nc.Set(key, 1, WithExpiration(-time.Second))
16-
19+
nc.Set(key, 1, WithExpiration(1*time.Second))
20+
nowFunc = func() time.Time {
21+
return time.Now().Add(2 * time.Second)
22+
}
1723
_, ok := nc.cache.Get(key)
1824
if !ok {
1925
t.Fatal("want true")

0 commit comments

Comments
 (0)