Skip to content

Commit 02fc173

Browse files
authored
fix: fix flake due to two time.Now() calls (#19450)
fixes coder/internal#559 This test is looking to see that after calling `coder schedule extend <workspace> 10h`, the scheduled stop time of the workspace is updated appropriately (or at least that the information printed to the terminal indicates that). By using two `time.Now()` calls for the current time and the expected time, there was the possibility that the second call just barely crossed over the hour mark. This is shown in the error message when the test would flake: `wanted "2025-04-07T22:"; got " 2025-04-07T23:00:00+05:30 \r\n"` (the 00:00 letting us know we just barely crossed the hour). Using the same time object to construct the expected time should fix the issue.
1 parent 9ad124d commit 02fc173

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cli/schedule_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ func TestScheduleOverride(t *testing.T) {
353353
ownerClient, _, _, ws := setupTestSchedule(t, sched)
354354
now := time.Now()
355355
// To avoid the likelihood of time-related flakes, only matching up to the hour.
356-
expectedDeadline := time.Now().In(loc).Add(10 * time.Hour).Format("2006-01-02T15:")
356+
expectedDeadline := now.In(loc).Add(10 * time.Hour).Format("2006-01-02T15:")
357357

358358
// When: we override the stop schedule
359359
inv, root := clitest.New(t,

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy