Skip to content

Commit

Permalink
[#781] Fix test cases on timer (ticking counts after timeout)
Browse files Browse the repository at this point in the history
- these tests were incorrectly asserting the number of ticks
- Go 1.23 introduces enhancements on timers and tickers
- Upgrading to 1.23 made the above errors apparent
  • Loading branch information
mengdaming committed Sep 25, 2024
1 parent c652e07 commit 8a050c6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/timer/periodic_reminder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ func Test_ticking_does_not_stop_after_timeout(t *testing.T) {
r := NewPeriodicReminder(testTimeout, testTickPeriod, func(ctx ReminderContext) {})
r.Start()
time.Sleep(testTimeout * 2)
assert.GreaterOrEqual(t, 4, r.tickCounter)
// There should be 2 ticks before the timeout fires.
// We should get more than 2 ticks in a period spawning 2 timeouts.
assert.Greater(t, r.tickCounter, 2)
assert.Equal(t, afterTimeOut, r.state)
}

Expand Down Expand Up @@ -141,7 +143,7 @@ func Test_keep_posting_reminders_after_timeout(t *testing.T) {
time.Sleep(testTimeout * 2)
r.Stop()

assert.GreaterOrEqual(t, 5, r.tickCounter)
assert.Equal(t, 5, r.tickCounter)
assert.Equal(t, stoppedAfterInterruption, r.state)
}

Expand Down

0 comments on commit 8a050c6

Please sign in to comment.