Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Commit

Permalink
changing timing on cache test to avoid races (#1606)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehelmick authored Jul 18, 2022
1 parent c49faaa commit 5411b07
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions pkg/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,19 @@ func TestMarkAndSweep(t *testing.T) {
t.Fatal(err)
}

checkSize(t, cache, 3)

timer := time.NewTimer(time.Millisecond * 150)
<-timer.C
// set two again so that it won't TTL
if err := cache.Set("two", orderTwo); err != nil {
t.Fatal(err)
for i := 0; i < 5; i++ {
<-timer.C
// set two again so that it won't TTL
if err := cache.Set("two", orderTwo); err != nil {
t.Fatal(err)
}
timer.Reset(time.Millisecond * 150)
}

checkSize(t, cache, 3)

timer.Reset(time.Millisecond * 200)
timer.Reset(time.Millisecond * 150)
<-timer.C

// entry "one" should have been purged
Expand Down

0 comments on commit 5411b07

Please sign in to comment.