forked from quic-go/quic-go
don't fire a newly created timer
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package utils
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
)
|
||||
|
||||
// A Timer wrapper that behaves correctly when resetting
|
||||
type Timer struct {
|
||||
@@ -11,7 +14,7 @@ type Timer struct {
|
||||
|
||||
// NewTimer creates a new timer that is not set
|
||||
func NewTimer() *Timer {
|
||||
return &Timer{t: time.NewTimer(0)}
|
||||
return &Timer{t: time.NewTimer(time.Duration(math.MaxInt64))}
|
||||
}
|
||||
|
||||
// Chan returns the channel of the wrapped timer
|
||||
|
||||
@@ -10,6 +10,11 @@ import (
|
||||
var _ = Describe("Timer", func() {
|
||||
const d = 10 * time.Millisecond
|
||||
|
||||
It("doesn't fire a newly created timer", func() {
|
||||
t := NewTimer()
|
||||
Consistently(t.Chan()).ShouldNot(Receive())
|
||||
})
|
||||
|
||||
It("works", func() {
|
||||
t := NewTimer()
|
||||
t.Reset(time.Now().Add(d))
|
||||
|
||||
Reference in New Issue
Block a user