Skip to content

Commit 791d39c

Browse files
test(coderd/database): use seperate context for subtests to fix flake (#19330)
Fixes flakes like https://github.com/coder/coder/actions/runs/16927282256/job/47965470039 https://coder.com/blog/go-testing-contexts-and-t-parallel ...I'm going to take a stab at turning this into a lint rule. I think it's possible by just reading the AST?
1 parent 117fa05 commit 791d39c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

coderd/database/querier_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6009,10 +6009,10 @@ func TestUserSecretsCRUDOperations(t *testing.T) {
60096009

60106010
// Use raw database without dbauthz wrapper for this test
60116011
db, _ := dbtestutil.NewDB(t)
6012-
ctx := testutil.Context(t, testutil.WaitMedium)
60136012

60146013
t.Run("FullCRUDWorkflow", func(t *testing.T) {
60156014
t.Parallel()
6015+
ctx := testutil.Context(t, testutil.WaitMedium)
60166016

60176017
// Create a new user for this test
60186018
testUser := dbgen.User(t, db, database.User{})
@@ -6085,6 +6085,7 @@ func TestUserSecretsCRUDOperations(t *testing.T) {
60856085

60866086
t.Run("UniqueConstraints", func(t *testing.T) {
60876087
t.Parallel()
6088+
ctx := testutil.Context(t, testutil.WaitMedium)
60886089

60896090
// Create a new user for this test
60906091
testUser := dbgen.User(t, db, database.User{})
@@ -6156,7 +6157,6 @@ func TestUserSecretsAuthorization(t *testing.T) {
61566157
db, _ := dbtestutil.NewDB(t)
61576158
authorizer := rbac.NewStrictCachingAuthorizer(prometheus.NewRegistry())
61586159
authDB := dbauthz.New(db, authorizer, slogtest.Make(t, &slogtest.Options{}), coderdtest.AccessControlStorePointer())
6159-
ctx := testutil.Context(t, testutil.WaitMedium)
61606160

61616161
// Create test users
61626162
user1 := dbgen.User(t, db, database.User{})
@@ -6234,6 +6234,7 @@ func TestUserSecretsAuthorization(t *testing.T) {
62346234
tc := tc // capture range variable
62356235
t.Run(tc.name, func(t *testing.T) {
62366236
t.Parallel()
6237+
ctx := testutil.Context(t, testutil.WaitMedium)
62376238

62386239
authCtx := dbauthz.As(ctx, tc.subject)
62396240

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy