Skip to content

Commit 4104c99

Browse files
Fix a slight race in a ticker test.
This is an incredibly unlikely race, but it shows up when running the test 30k+ times on my system. The problem is that it's possible for: * the fake clock to unblock the ticker * the test attempt to read from the channel before the ticker sends This is more likely in the new implementation than the old implementation before there is slightly more logic between the next tick reception and the tick send.
1 parent 06008c2 commit 4104c99

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

ticker_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestFakeTickerTick(t *testing.T) {
3939
if tick != first {
4040
t.Errorf("wrong tick time, got: %v, want: %v", tick, first)
4141
}
42-
default:
42+
case <-time.After(time.Millisecond):
4343
t.Errorf("expected tick!")
4444
}
4545

@@ -52,7 +52,7 @@ func TestFakeTickerTick(t *testing.T) {
5252
if tick != second {
5353
t.Errorf("wrong tick time, got: %v, want: %v", tick, second)
5454
}
55-
default:
55+
case <-time.After(time.Millisecond):
5656
t.Errorf("expected tick!")
5757
}
5858
ft.Stop()

0 commit comments

Comments
 (0)