From 13307c5a2442aef0a9b70553c428e2a60e9b968c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 10 Jun 2022 14:53:23 +0200 Subject: [PATCH] Manager: add canary test to timeout checker unit test The `TestTaskTimeout()` unit test assumes specific durations for initial & subsequent sleeps of the timeout checker. The test will fail quite cryptically when that assumption doesn't hold, so just test for it at the start of the unit test. --- internal/manager/timeout_checker/timeout_checker_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/internal/manager/timeout_checker/timeout_checker_test.go b/internal/manager/timeout_checker/timeout_checker_test.go index c3a5f2b3..94d68ab6 100644 --- a/internal/manager/timeout_checker/timeout_checker_test.go +++ b/internal/manager/timeout_checker/timeout_checker_test.go @@ -82,6 +82,13 @@ func TestTimeoutCheckerTiming(t *testing.T) { } func TestTaskTimeout(t *testing.T) { + // Canary test: if these constants do not have the expected value, the test + // will fail rather cryptically. + if !assert.Equal(t, 5*time.Minute, timeoutInitialSleep, "timeoutInitialSleep does not have the expected value") || + !assert.Equal(t, 1*time.Minute, timeoutCheckInterval, "timeoutCheckInterval does not have the expected value") { + t.FailNow() + } + ttc, finish, mocks := timeoutCheckerTestFixtures(t) defer finish()