MCPcopy Index your code
hub / github.com/coder/coder / TestExecutorAutostartNotEnabled

Function TestExecutorAutostartNotEnabled

coderd/autobuild/lifecycle_executor_test.go:349–382  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

347}
348
349func TestExecutorAutostartNotEnabled(t *testing.T) {
350 t.Parallel()
351
352 var (
353 tickCh = make(chan time.Time)
354 statsCh = make(chan autobuild.Stats)
355 client = coderdtest.New(t, &coderdtest.Options{
356 AutobuildTicker: tickCh,
357 IncludeProvisionerDaemon: true,
358 AutobuildStats: statsCh,
359 })
360 // Given: we have a user with a workspace that does not have autostart enabled
361 workspace = mustProvisionWorkspace(t, client, func(cwr *codersdk.CreateWorkspaceRequest) {
362 cwr.AutostartSchedule = nil
363 })
364 )
365
366 // Given: workspace does not have autostart enabled
367 require.Empty(t, workspace.AutostartSchedule)
368
369 // Given: workspace is stopped
370 workspace = coderdtest.MustTransitionWorkspace(t, client, workspace.ID, codersdk.WorkspaceTransitionStart, codersdk.WorkspaceTransitionStop)
371
372 // When: the autobuild executor ticks way into the future
373 go func() {
374 tickCh <- workspace.LatestBuild.CreatedAt.Add(24 * time.Hour)
375 close(tickCh)
376 }()
377
378 // Then: the workspace should not be started.
379 stats := <-statsCh
380 assert.Len(t, stats.Errors, 0)
381 require.Len(t, stats.Transitions, 0)
382}
383
384func TestExecutorAutostartUserSuspended(t *testing.T) {
385 t.Parallel()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
MustTransitionWorkspaceFunction · 0.92
mustProvisionWorkspaceFunction · 0.85
AddMethod · 0.65
EmptyMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected