Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a6255d6

Browse files
committed
GREEN: fix final unit test
1 parent a5ec9bf commit a6255d6

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)