File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package cache
2
2
3
3
import (
4
4
"context"
5
+ "sync/atomic"
5
6
"testing"
6
7
"time"
7
8
)
@@ -15,8 +16,8 @@ func TestJanitor(t *testing.T) {
15
16
checkDone := make (chan struct {})
16
17
janitor .done = checkDone
17
18
18
- calledClean := false
19
- janitor .run (func () { calledClean = true })
19
+ calledClean := int64 ( 0 )
20
+ janitor .run (func () { atomic . AddInt64 ( & calledClean , 1 ) })
20
21
21
22
// waiting for cleanup
22
23
time .Sleep (10 * time .Millisecond )
@@ -28,7 +29,8 @@ func TestJanitor(t *testing.T) {
28
29
t .Fatalf ("failed to call done channel" )
29
30
}
30
31
31
- if ! calledClean {
32
- t .Fatal ("failed to call clean callback in janitor" )
32
+ got := atomic .LoadInt64 (& calledClean )
33
+ if got <= 1 {
34
+ t .Fatalf ("failed to call clean callback in janitor: %d" , got )
33
35
}
34
36
}
You can’t perform that action at this time.
0 commit comments