Skip to content

Commit 8343b8e

Browse files
committed
GREEN: fix final unit test
1 parent 1af266f commit 8343b8e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

coderd/autobuild/executor/lifecycle_executor_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,7 @@ func TestExecutorAutostartMultipleOK(t *testing.T) {
456456
t.Parallel()
457457

458458
var (
459+
sched = mustSchedule(t, "CRON_TZ=UTC 0 * * * *")
459460
tickCh = make(chan time.Time)
460461
tickCh2 = make(chan time.Time)
461462
statsCh1 = make(chan executor.Stats)
@@ -471,15 +472,17 @@ func TestExecutorAutostartMultipleOK(t *testing.T) {
471472
AutobuildStats: statsCh2,
472473
})
473474
// Given: we have a user with a workspace that has autostart enabled (default)
474-
workspace = mustProvisionWorkspace(t, client)
475+
workspace = mustProvisionWorkspace(t, client, func(cwr *codersdk.CreateWorkspaceRequest) {
476+
cwr.AutostartSchedule = ptr.Ref(sched.String())
477+
})
475478
)
476479
// Given: workspace is stopped
477480
workspace = mustTransitionWorkspace(t, client, workspace.ID, database.WorkspaceTransitionStart, database.WorkspaceTransitionStop)
478481

479-
// When: the autobuild executor ticks
482+
// When: the autobuild executor ticks past the scheduled time
480483
go func() {
481-
tickCh <- time.Now().UTC().Add(time.Minute)
482-
tickCh2 <- time.Now().UTC().Add(time.Minute)
484+
tickCh <- sched.Next(workspace.LatestBuild.CreatedAt)
485+
tickCh2 <- sched.Next(workspace.LatestBuild.CreatedAt)
483486
close(tickCh)
484487
close(tickCh2)
485488
}()

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