diff --git a/common/repeat_timer.go b/common/repeat_timer.go index 7c5291844..96348bd19 100644 --- a/common/repeat_timer.go +++ b/common/repeat_timer.go @@ -36,7 +36,8 @@ func (t *defaultTicker) Chan() <-chan time.Time { // Implements Ticker func (t *defaultTicker) Stop() { - t.Stop() + tt := time.Ticker(*t) + tt.Stop() } //---------------------------------------- diff --git a/common/repeat_timer_test.go b/common/repeat_timer_test.go index 44a1a0679..269316bd2 100644 --- a/common/repeat_timer_test.go +++ b/common/repeat_timer_test.go @@ -7,8 +7,12 @@ import ( "github.com/stretchr/testify/assert" ) -// NOTE: this only tests with the LogicalTicker. -// How do you test a real-clock ticker properly? +func TestDefaultTicker(t *testing.T) { + ticker := defaultTickerMaker(time.Millisecond * 10) + <-ticker.Chan() + ticker.Stop() +} + func TestRepeat(t *testing.T) { ch := make(chan time.Time, 100)