(t *testing.T)
| 347 | } |
| 348 | |
| 349 | func 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 | |
| 384 | func TestExecutorAutostartUserSuspended(t *testing.T) { |
| 385 | t.Parallel() |
nothing calls this directly
no test coverage detected