add test for manually triggered calls

This commit is contained in:
dave 2024-06-17 18:34:23 -07:00
parent fb4f17791e
commit cfbbad3ff0
2 changed files with 9 additions and 1 deletions

View File

@ -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)
}

View File

@ -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")
}
}