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

Function TestExecutorWorkspaceDeleted

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

Source from the content-addressed store, hash-verified

685}
686
687func TestExecutorWorkspaceDeleted(t *testing.T) {
688 t.Parallel()
689
690 var (
691 sched = mustSchedule(t, "CRON_TZ=UTC 0 * * * *")
692 tickCh = make(chan time.Time)
693 statsCh = make(chan autobuild.Stats)
694 client = coderdtest.New(t, &coderdtest.Options{
695 AutobuildTicker: tickCh,
696 IncludeProvisionerDaemon: true,
697 AutobuildStats: statsCh,
698 })
699 // Given: we have a user with a workspace that has autostart enabled
700 workspace = mustProvisionWorkspace(t, client, func(cwr *codersdk.CreateWorkspaceRequest) {
701 cwr.AutostartSchedule = ptr.Ref(sched.String())
702 })
703 )
704
705 // Given: workspace is deleted
706 workspace = coderdtest.MustTransitionWorkspace(t, client, workspace.ID, codersdk.WorkspaceTransitionStart, codersdk.WorkspaceTransitionDelete)
707
708 // When: the autobuild executor ticks
709 go func() {
710 tickCh <- sched.Next(workspace.LatestBuild.CreatedAt)
711 close(tickCh)
712 }()
713
714 // Then: nothing should happen
715 stats := <-statsCh
716 assert.Len(t, stats.Errors, 0)
717 assert.Len(t, stats.Transitions, 0)
718}
719
720func TestExecutorWorkspaceAutostartTooEarly(t *testing.T) {
721 t.Parallel()

Callers

nothing calls this directly

Calls 8

NewFunction · 0.92
RefFunction · 0.92
MustTransitionWorkspaceFunction · 0.92
mustProvisionWorkspaceFunction · 0.85
mustScheduleFunction · 0.70
NextMethod · 0.65
StringMethod · 0.45
LenMethod · 0.45

Tested by

no test coverage detected