Browse Source

fix recursion

pull/1842/head
Ethan Buchman 7 years ago
parent
commit
558f8e7769
2 changed files with 8 additions and 3 deletions
  1. +2
    -1
      common/repeat_timer.go
  2. +6
    -2
      common/repeat_timer_test.go

+ 2
- 1
common/repeat_timer.go View File

@ -36,7 +36,8 @@ func (t *defaultTicker) Chan() <-chan time.Time {
// Implements Ticker // Implements Ticker
func (t *defaultTicker) Stop() { func (t *defaultTicker) Stop() {
t.Stop()
tt := time.Ticker(*t)
tt.Stop()
} }
//---------------------------------------- //----------------------------------------


+ 6
- 2
common/repeat_timer_test.go View File

@ -7,8 +7,12 @@ import (
"github.com/stretchr/testify/assert" "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) { func TestRepeat(t *testing.T) {
ch := make(chan time.Time, 100) ch := make(chan time.Time, 100)


Loading…
Cancel
Save