tile38/vendor/github.com/nats-io/go-nats/timer_test.go

30 lines
393 B
Go
Raw Normal View History

2018-08-07 22:21:35 +03:00
package nats
import (
"testing"
"time"
)
func TestTimerPool(t *testing.T) {
var tp timerPool
for i := 0; i < 10; i++ {
tm := tp.Get(time.Millisecond * 20)
select {
case <-tm.C:
t.Errorf("Timer already expired")
continue
default:
}
select {
case <-tm.C:
case <-time.After(time.Millisecond * 100):
t.Errorf("Timer didn't expire in time")
}
tp.Put(tm)
}
}