(t *testing.T)
| 647 | } |
| 648 | |
| 649 | func TestExecutorAutostopNotEnabled(t *testing.T) { |
| 650 | t.Parallel() |
| 651 | |
| 652 | var ( |
| 653 | tickCh = make(chan time.Time) |
| 654 | statsCh = make(chan autobuild.Stats) |
| 655 | client = coderdtest.New(t, &coderdtest.Options{ |
| 656 | AutobuildTicker: tickCh, |
| 657 | IncludeProvisionerDaemon: true, |
| 658 | AutobuildStats: statsCh, |
| 659 | }) |
| 660 | // Given: we have a user with a workspace |
| 661 | workspace = mustProvisionWorkspace(t, client, func(cwr *codersdk.CreateWorkspaceRequest) { |
| 662 | cwr.TTLMillis = nil |
| 663 | }) |
| 664 | ) |
| 665 | |
| 666 | // Given: workspace has no TTL set |
| 667 | workspace = coderdtest.MustWorkspace(t, client, workspace.ID) |
| 668 | require.Nil(t, workspace.TTLMillis) |
| 669 | require.Zero(t, workspace.LatestBuild.Deadline) |
| 670 | require.NotZero(t, workspace.LatestBuild.Job.CompletedAt) |
| 671 | |
| 672 | // Given: workspace is running |
| 673 | require.Equal(t, codersdk.WorkspaceTransitionStart, workspace.LatestBuild.Transition) |
| 674 | |
| 675 | // When: the autobuild executor ticks a year in the future |
| 676 | go func() { |
| 677 | tickCh <- workspace.LatestBuild.Job.CompletedAt.AddDate(1, 0, 0) |
| 678 | close(tickCh) |
| 679 | }() |
| 680 | |
| 681 | // Then: the workspace should not be stopped. |
| 682 | stats := <-statsCh |
| 683 | assert.Len(t, stats.Errors, 0) |
| 684 | assert.Len(t, stats.Transitions, 0) |
| 685 | } |
| 686 | |
| 687 | func TestExecutorWorkspaceDeleted(t *testing.T) { |
| 688 | t.Parallel() |
nothing calls this directly
no test coverage detected