@@ -456,6 +456,7 @@ func TestExecutorAutostartMultipleOK(t *testing.T) {
456
456
t .Parallel ()
457
457
458
458
var (
459
+ sched = mustSchedule (t ,"CRON_TZ=UTC 0 * * * *" )
459
460
tickCh = make (chan time.Time )
460
461
tickCh2 = make (chan time.Time )
461
462
statsCh1 = make (chan executor.Stats )
@@ -471,15 +472,17 @@ func TestExecutorAutostartMultipleOK(t *testing.T) {
471
472
AutobuildStats :statsCh2 ,
472
473
})
473
474
// 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
+ })
475
478
)
476
479
// Given: workspace is stopped
477
480
workspace = mustTransitionWorkspace (t ,client ,workspace .ID ,database .WorkspaceTransitionStart ,database .WorkspaceTransitionStop )
478
481
479
- // When: the autobuild executor ticks
482
+ // When: the autobuild executor ticks past the scheduled time
480
483
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 )
483
486
close (tickCh )
484
487
close (tickCh2 )
485
488
}()