Closed pcman312 closed 3 years ago
fakeClock does not handle negative durations passed to After() correctly.
fakeClock
After()
This looks very similar to https://github.com/jonboulle/clockwork/issues/19
func TestNegativeTimer(t *testing.T) { fakeClock := clockwork.NewFakeClock() timer := time.NewTimer(2 * time.Second) defer timer.Stop() select { case <-fakeClock.After(-1 * time.Second): // Success case <-timer.C: t.Fatalf("Timed out!") } }
Output:
$ go test -v -run TestNegativeTimer === RUN TestNegativeTimer --- FAIL: TestNegativeTimer (2.00s) negativetimer_test.go:18: Timed out! FAIL exit status 1
Just opened a PR for a fix https://github.com/jonboulle/clockwork/pull/24
Description
fakeClock
does not handle negative durations passed toAfter()
correctly.This looks very similar to https://github.com/jonboulle/clockwork/issues/19
Steps to reproduce
Output: