From f45a179181e21acd1f816ebc7deb7814083d3ce1 Mon Sep 17 00:00:00 2001 From: Danielle Maywood Date: Thu, 11 Dec 2025 21:51:16 +0000 Subject: [PATCH] test: move context to after db creation (#21224) Closes https://github.com/coder/internal/issues/1040 We move the context to just before it is used to avoid the scenario where NewDB takes a while to spin up and runs up the context to the deadline. --- coderd/database/querier_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coderd/database/querier_test.go b/coderd/database/querier_test.go index 6c8b5d097b..82c118248c 100644 --- a/coderd/database/querier_test.go +++ b/coderd/database/querier_test.go @@ -6082,8 +6082,6 @@ func TestGetWorkspaceAgentsByParentID(t *testing.T) { t.Run("NilParentDoesNotReturnAllParentAgents", func(t *testing.T) { t.Parallel() - ctx := testutil.Context(t, testutil.WaitShort) - // Given: A workspace agent db, _ := dbtestutil.NewDB(t) org := dbgen.Organization(t, db, database.Organization{}) @@ -6098,6 +6096,8 @@ func TestGetWorkspaceAgentsByParentID(t *testing.T) { ResourceID: resource.ID, }) + ctx := testutil.Context(t, testutil.WaitShort) + // When: We attempt to select agents with a null parent id agents, err := db.GetWorkspaceAgentsByParentID(ctx, uuid.Nil) require.NoError(t, err)