Skip to content

Commit 4825b7c

Browse files
authored
fix: use new context after t.Parallel in TestOAuthAppSecrets
c.f. https://coder.com/blog/go-testing-contexts-and-t-parallel fixes flakes like https://github.com/coder/coder/runs/20856469613
1 parent de6d479 commit 4825b7c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

enterprise/coderd/oauth2_test.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -271,25 +271,26 @@ func TestOAuthAppSecrets(t *testing.T) {
271271
},
272272
}})
273273

274-
ctx := testutil.Context(t, testutil.WaitLong)
274+
topCtx := testutil.Context(t, testutil.WaitLong)
275275

276276
// Make some apps.
277277
//nolint:gocritic // OAauth2 app management requires owner permission.
278-
app1, err := client.PostOAuth2ProviderApp(ctx, codersdk.PostOAuth2ProviderAppRequest{
278+
app1, err := client.PostOAuth2ProviderApp(topCtx, codersdk.PostOAuth2ProviderAppRequest{
279279
Name: "razzle-dazzle",
280280
CallbackURL: "http://localhost",
281281
})
282282
require.NoError(t, err)
283283

284284
//nolint:gocritic // OAauth2 app management requires owner permission.
285-
app2, err := client.PostOAuth2ProviderApp(ctx, codersdk.PostOAuth2ProviderAppRequest{
285+
app2, err := client.PostOAuth2ProviderApp(topCtx, codersdk.PostOAuth2ProviderAppRequest{
286286
Name: "razzle-dazzle-the-sequel",
287287
CallbackURL: "http://localhost",
288288
})
289289
require.NoError(t, err)
290290

291291
t.Run("DeleteNonExisting", func(t *testing.T) {
292292
t.Parallel()
293+
ctx := testutil.Context(t, testutil.WaitLong)
293294

294295
// Should not be able to create secrets for a non-existent app.
295296
//nolint:gocritic // OAauth2 app management requires owner permission.
@@ -318,6 +319,7 @@ func TestOAuthAppSecrets(t *testing.T) {
318319

319320
t.Run("OK", func(t *testing.T) {
320321
t.Parallel()
322+
ctx := testutil.Context(t, testutil.WaitLong)
321323

322324
// No secrets yet.
323325
//nolint:gocritic // OAauth2 app management requires owner permission.

0 commit comments

Comments
 (0)