Ticker chan sometimes doesn't fire
Closed this issue · 1 comments
jacobmbr commented
I have this test:
func TestMockClock(t *testing.T) {
clk := clock.NewMockClock()
ticker := clk.NewTicker(250 * time.Millisecond)
clk.AddTime(251 * time.Millisecond)
select {
case <-ticker.Chan():
return
case <-time.After(time.Second):
t.Fatal("Timed out waiting for test to complete")
}
}
If I run this test a bunch of times, it fails:
$ go test . -run TestMockClock -count 100000 -failfast
[... a bunch of successful runs ...]
--- FAIL: TestMockClock (1.00s)
pinger_test.go:40: Timed out waiting for test to complete
FAIL
FAIL github.com/symbiont-io/assembly/smartlog/lib/network 1.169s
Is there something wrong with my test setup?