don't set a timer when the deadline is the zero value

This commit is contained in:
Marten Seemann
2018-12-16 21:04:39 +06:30
parent 072b84870c
commit 516b427d46
2 changed files with 9 additions and 1 deletions

View File

@@ -54,6 +54,12 @@ var _ = Describe("Timer", func() {
Eventually(t.Chan()).Should(Receive())
})
It("doesn't set a timer if the deadline is the zero value", func() {
t := NewTimer()
t.Reset(time.Time{})
Consistently(t.Chan()).ShouldNot(Receive())
})
It("fires the timer twice, if reset to the same deadline", func() {
deadline := time.Now().Add(-time.Millisecond)
t := NewTimer()