Skip to content

Commit 9d79cd1

Browse files
committedFeb 9, 2024
Fix a racy context
And rename another, it is not being used incorrectly, but the name makes it clear.
1 parent cbefdb2 commit 9d79cd1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

‎enterprise/coderd/oauth2_test.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestOAuth2ProviderApps(t *testing.T) {
3939
},
4040
}})
4141

42-
ctx := testutil.Context(t, testutil.WaitLong)
42+
topCtx := testutil.Context(t, testutil.WaitLong)
4343

4444
tests := []struct {
4545
name string
@@ -142,7 +142,7 @@ func TestOAuth2ProviderApps(t *testing.T) {
142142
CallbackURL: "http://coder.com",
143143
}
144144
//nolint:gocritic // OAauth2 app management requires owner permission.
145-
_, err := client.PostOAuth2ProviderApp(ctx, req)
145+
_, err := client.PostOAuth2ProviderApp(topCtx, req)
146146
require.NoError(t, err)
147147

148148
// Generate an application for testing PUTs.
@@ -151,13 +151,14 @@ func TestOAuth2ProviderApps(t *testing.T) {
151151
CallbackURL: "http://coder.com",
152152
}
153153
//nolint:gocritic // OAauth2 app management requires owner permission.
154-
existingApp, err := client.PostOAuth2ProviderApp(ctx, req)
154+
existingApp, err := client.PostOAuth2ProviderApp(topCtx, req)
155155
require.NoError(t, err)
156156

157157
for _, test := range tests {
158158
test := test
159159
t.Run(test.name, func(t *testing.T) {
160160
t.Parallel()
161+
ctx := testutil.Context(t, testutil.WaitLong)
161162

162163
//nolint:gocritic // OAauth2 app management requires owner permission.
163164
_, err := client.PostOAuth2ProviderApp(ctx, test.req)
@@ -392,11 +393,11 @@ func TestOAuth2ProviderTokenExchange(t *testing.T) {
392393
},
393394
},
394395
})
395-
ctx := testutil.Context(t, testutil.WaitLong)
396-
apps := generateApps(ctx, t, ownerClient, "token-exchange")
396+
topCtx := testutil.Context(t, testutil.WaitLong)
397+
apps := generateApps(topCtx, t, ownerClient, "token-exchange")
397398

398399
//nolint:gocritic // OAauth2 app management requires owner permission.
399-
secret, err := ownerClient.PostOAuth2ProviderAppSecret(ctx, apps.Default.ID)
400+
secret, err := ownerClient.PostOAuth2ProviderAppSecret(topCtx, apps.Default.ID)
400401
require.NoError(t, err)
401402

402403
// The typical oauth2 flow from this point is:

0 commit comments

Comments
 (0)