We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 62b62f2 commit 6298b34Copy full SHA for 6298b34
cache_internal_test.go
@@ -9,11 +9,17 @@ import (
9
func TestDeletedCache(t *testing.T) {
10
ctx, cancel := context.WithCancel(context.Background())
11
defer cancel()
12
+ restore := func() {
13
+ nowFunc = time.Now
14
+ }
15
+ defer restore()
16
17
nc := NewContext[string, int](ctx)
18
key := "key"
- nc.Set(key, 1, WithExpiration(-time.Second))
-
19
+ nc.Set(key, 1, WithExpiration(1*time.Second))
20
+ nowFunc = func() time.Time {
21
+ return time.Now().Add(2 * time.Second)
22
23
_, ok := nc.cache.Get(key)
24
if !ok {
25
t.Fatal("want true")
0 commit comments