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

Function TestExecutorAutostopNotEnabled

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

Source from the content-addressed store, hash-verified

647}
648
649func 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
687func TestExecutorWorkspaceDeleted(t *testing.T) {
688 t.Parallel()

Callers

nothing calls this directly

Calls 5

NewFunction · 0.92
MustWorkspaceFunction · 0.92
mustProvisionWorkspaceFunction · 0.85
EqualMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected