From 558f8e77699286ffca1f59842f54160dd30d4794 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 25 Dec 2017 11:10:48 -0500 Subject: [PATCH] fix recursion --- common/repeat_timer.go | 3 ++- common/repeat_timer_test.go | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) 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)