(t *testing.T)
| 685 | } |
| 686 | |
| 687 | func 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 | |
| 720 | func TestExecutorWorkspaceAutostartTooEarly(t *testing.T) { |
| 721 | t.Parallel() |
nothing calls this directly
no test coverage detected