Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions common/countdown/countdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ firstReset:
}
}

// Now the countdown is paused after calling the callback function, let's reset it again
// The countdown keeps running after calling the callback; it is still initialised.
// Reset it again to verify that an explicit Reset extends the timeout by a full interval.
assert.True(t, countdown.isInitilised())
countdown.Reset(fakeI, 0, 0)
expectedTimeAfterReset := time.Now().Add(5000 * time.Millisecond)
<-called
// Always initilised
assert.True(t, countdown.isInitilised())
if time.Now().After(expectedTimeAfterReset) {
if !time.Now().Before(expectedTimeAfterReset) {
t.Log("Correctly reset the countdown second time")
} else {
t.Fatalf("Countdown did not reset correctly second time")
Expand Down Expand Up @@ -109,13 +111,15 @@ firstReset:
}
}

// Now the countdown is paused after calling the callback function, let's reset it again
// The countdown continues running (auto-resets) after calling the callback
// function; reset it again to verify it can still be reset after an error
assert.True(t, countdown.isInitilised())
countdown.Reset(fakeI, 0, 0)
expectedTimeAfterReset := time.Now().Add(5000 * time.Millisecond)
<-called
// Always initilised
assert.True(t, countdown.isInitilised())
if time.Now().After(expectedTimeAfterReset) {
if !time.Now().Before(expectedTimeAfterReset) {
t.Log("Correctly reset the countdown second time")
} else {
t.Fatalf("Countdown did not reset correctly second time")
Expand Down