Skip to content

Commit

Permalink
try to silence race detector
Browse files Browse the repository at this point in the history
  • Loading branch information
lestrrat committed Mar 22, 2022
1 parent 9533560 commit c13da17
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions httprc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ func (d *dummyErrSink) Error(err error) {
d.errors = append(d.errors, err)
}

func (d *dummyErrSink) getErrors() []error {
d.mu.RLock()
defer d.mu.RUnlock()
return d.errors
}

func TestCache(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down Expand Up @@ -100,8 +106,7 @@ func TestCache(t *testing.T) {
time.Sleep(3 * time.Second)
cancel()

time.Sleep(time.Second)
if !assert.True(t, len(errSink.errors) > 0) {
if !assert.True(t, len(errSink.getErrors()) > 0) {
return
}
}

0 comments on commit c13da17

Please sign in to comment.