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.
This commit is contained in:
Danielle Maywood
2025-12-11 21:51:16 +00:00
committed by GitHub
parent c44a2c3a9b
commit f45a179181
+2 -2
View File
@@ -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)