From cfbbad3ff04c0fb6dddb80d54724cc2798b167f9 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 17 Jun 2024 18:34:23 -0700 Subject: [PATCH] add test for manually triggered calls --- ticker.go | 2 +- ticker_test.go | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ticker.go b/ticker.go index 802d439..74b07a7 100644 --- a/ticker.go +++ b/ticker.go @@ -29,7 +29,7 @@ func (c *CallTicker) Reset(d time.Duration) { c.ticker.Reset(d) } -func (c *CallTicker) Trigger() { +func (c *CallTicker) Force() { c.manualTrigger <- true c.Reset(c.duration) } diff --git a/ticker_test.go b/ticker_test.go index c7cdb6e..d644076 100644 --- a/ticker_test.go +++ b/ticker_test.go @@ -28,4 +28,12 @@ func TestTicker(t *testing.T) { if num != 5 { t.Errorf("expected calls to stop") } + + ticker.Force() + time.Sleep(time.Millisecond * 10) + + if num != 6 { + t.Errorf("forced call did not run") + } + }