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
22
33import (
44 "context"
5+ "sync/atomic"
56 "testing"
67 "time"
78)
@@ -15,8 +16,8 @@ func TestJanitor(t *testing.T) {
1516 checkDone := make (chan struct {})
1617 janitor .done = checkDone
1718
18- calledClean := false
19- janitor .run (func () { calledClean = true })
19+ calledClean := int64 ( 0 )
20+ janitor .run (func () { atomic . AddInt64 ( & calledClean , 1 ) })
2021
2122 // waiting for cleanup
2223 time .Sleep (10 * time .Millisecond )
@@ -28,7 +29,8 @@ func TestJanitor(t *testing.T) {
2829 t .Fatalf ("failed to call done channel" )
2930 }
3031
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 )
3335 }
3436}
You can’t perform that action at this time.
0 commit comments