From a4ce5f6309e0398cefae9fe95f7d55cd4c89b5bd Mon Sep 17 00:00:00 2001 From: Susana Ferreira Date: Tue, 15 Jul 2025 09:12:24 +0000 Subject: [PATCH] fix(cli): flake test in prebuilt workspace delete by scoping context per subtest --- cli/delete_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/delete_test.go b/cli/delete_test.go index a48ca98627f65..c01893419f80f 100644 --- a/cli/delete_test.go +++ b/cli/delete_test.go @@ -233,9 +233,6 @@ func TestDelete(t *testing.T) { t.Skip("this test requires postgres") } - clock := quartz.NewMock(t) - ctx := testutil.Context(t, testutil.WaitSuperLong) - // Setup db, pb := dbtestutil.NewDB(t, dbtestutil.WithDumpOnFailure()) client, _ := coderdtest.NewWithProvisionerCloser(t, &coderdtest.Options{ @@ -301,6 +298,9 @@ func TestDelete(t *testing.T) { t.Run(tc.name, func(t *testing.T) { t.Parallel() + clock := quartz.NewMock(t) + ctx := testutil.Context(t, testutil.WaitSuperLong) + // Create one prebuilt workspace (owned by system user) and one normal workspace (owned by a user) // Each workspace is persisted in the DB along with associated workspace jobs and builds. dbPrebuiltWorkspace := setupTestDBWorkspace(t, clock, db, pb, orgID, database.PrebuildsSystemUserID, template.ID, version.ID, preset.ID)