WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 4014eeb

Browse files
gaultierory-bot
authored andcommitted
test: fix data races
GitOrigin-RevId: 7dc520ddc926be30393d474734d37a5f58cc4851
1 parent 791b0d5 commit 4014eeb

File tree

3 files changed

+80
-17
lines changed

3 files changed

+80
-17
lines changed

driver/registry_default_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ func TestDriverDefault_Hooks(t *testing.T) {
3535
t.Parallel()
3636
ctx := context.Background()
3737

38-
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
39-
4038
t.Run("type=verification", func(t *testing.T) {
4139
t.Parallel()
4240
// BEFORE hooks
41+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
4342
for _, tc := range []struct {
4443
uc string
4544
config map[string]any
@@ -155,6 +154,7 @@ func TestDriverDefault_Hooks(t *testing.T) {
155154

156155
ctx := contextx.WithConfigValues(ctx, tc.config)
157156

157+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
158158
h, err := reg.PreRecoveryHooks(ctx)
159159
require.NoError(t, err)
160160

@@ -193,6 +193,7 @@ func TestDriverDefault_Hooks(t *testing.T) {
193193

194194
ctx := contextx.WithConfigValues(ctx, tc.config)
195195

196+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
196197
h, err := reg.PostRecoveryHooks(ctx)
197198
require.NoError(t, err)
198199

@@ -236,6 +237,7 @@ func TestDriverDefault_Hooks(t *testing.T) {
236237

237238
ctx := contextx.WithConfigValues(ctx, tc.config)
238239

240+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
239241
h, err := reg.PreRegistrationHooks(ctx)
240242
require.NoError(t, err)
241243

@@ -341,6 +343,7 @@ func TestDriverDefault_Hooks(t *testing.T) {
341343

342344
ctx := contextx.WithConfigValues(ctx, tc.config)
343345

346+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
344347
h, err := reg.PostRegistrationPostPersistHooks(ctx, identity.CredentialsTypePassword)
345348
require.NoError(t, err)
346349

@@ -382,6 +385,7 @@ func TestDriverDefault_Hooks(t *testing.T) {
382385

383386
ctx := contextx.WithConfigValues(ctx, tc.config)
384387

388+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
385389
h, err := reg.PreLoginHooks(ctx)
386390
require.NoError(t, err)
387391

@@ -483,6 +487,7 @@ func TestDriverDefault_Hooks(t *testing.T) {
483487

484488
ctx := contextx.WithConfigValues(ctx, tc.config)
485489

490+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
486491
h, err := reg.PostLoginHooks(ctx, identity.CredentialsTypePassword)
487492
require.NoError(t, err)
488493

@@ -524,6 +529,7 @@ func TestDriverDefault_Hooks(t *testing.T) {
524529

525530
ctx := contextx.WithConfigValues(ctx, tc.config)
526531

532+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
527533
h, err := reg.PreSettingsHooks(ctx)
528534
require.NoError(t, err)
529535

@@ -611,6 +617,7 @@ func TestDriverDefault_Hooks(t *testing.T) {
611617

612618
ctx := contextx.WithConfigValues(ctx, tc.config)
613619

620+
_, reg := internal.NewVeryFastRegistryWithoutDB(t)
614621
h, err := reg.PostSettingsPostPersistHooks(ctx, "profile")
615622
require.NoError(t, err)
616623

persistence/sql/migratest/migration_test.go

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -140,27 +140,28 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
140140
})
141141

142142
wg := &sync.WaitGroup{}
143-
144-
d, err := driver.New(
145-
context.Background(),
146-
os.Stderr,
147-
driver.WithConfigOptions(
148-
configx.WithValues(map[string]any{
149-
config.ViperKeyDSN: url,
150-
config.ViperKeyPublicBaseURL: "https://www.ory.sh/",
151-
config.ViperKeyIdentitySchemas: config.Schemas{{ID: "default", URL: "file://stub/default.schema.json"}},
152-
config.ViperKeySecretsDefault: []string{"secret"},
153-
}),
154-
configx.SkipValidation(),
155-
),
143+
opts := driver.WithConfigOptions(
144+
configx.WithValues(map[string]any{
145+
config.ViperKeyDSN: url,
146+
config.ViperKeyPublicBaseURL: "https://www.ory.sh/",
147+
config.ViperKeyIdentitySchemas: config.Schemas{{ID: "default", URL: "file://stub/default.schema.json"}},
148+
config.ViperKeySecretsDefault: []string{"secret"},
149+
}),
150+
configx.SkipValidation(),
156151
)
157-
require.NoError(t, err)
158152

159153
t.Run("case=identity", func(t *testing.T) {
160154
wg.Add(1)
161155
defer wg.Done()
162156
t.Parallel()
163157

158+
d, err := driver.New(
159+
context.Background(),
160+
os.Stderr,
161+
opts,
162+
)
163+
require.NoError(t, err)
164+
164165
ids, _, err := d.PrivilegedIdentityPool().ListIdentities(context.Background(), identity.ListIdentityParameters{Expand: identity.ExpandEverything, KeySetPagination: []keysetpagination.Option{keysetpagination.WithSize(1000)}})
165166
require.NoError(t, err)
166167
require.NotEmpty(t, ids)
@@ -189,6 +190,13 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
189190
defer wg.Done()
190191
t.Parallel()
191192

193+
d, err := driver.New(
194+
context.Background(),
195+
os.Stderr,
196+
opts,
197+
)
198+
require.NoError(t, err)
199+
192200
ids, _, err := d.PrivilegedIdentityPool().ListIdentities(context.Background(), identity.ListIdentityParameters{Expand: identity.ExpandNothing, KeySetPagination: []keysetpagination.Option{keysetpagination.WithSize(1000)}})
193201
require.NoError(t, err)
194202
require.NotEmpty(t, ids)
@@ -229,6 +237,13 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
229237
require.NoError(t, c.Select("id").All(&ids))
230238
require.NotEmpty(t, ids)
231239

240+
d, err := driver.New(
241+
context.Background(),
242+
os.Stderr,
243+
opts,
244+
)
245+
require.NoError(t, err)
246+
232247
var found []string
233248
for _, id := range ids {
234249
found = append(found, id.ID.String())
@@ -249,6 +264,13 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
249264
require.NoError(t, c.Select("id").All(&ids))
250265
require.NotEmpty(t, ids)
251266

267+
d, err := driver.New(
268+
context.Background(),
269+
os.Stderr,
270+
opts,
271+
)
272+
require.NoError(t, err)
273+
252274
var found []string
253275
for _, id := range ids {
254276
found = append(found, id.ID.String())
@@ -268,6 +290,13 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
268290
require.NoError(t, c.Select("id").All(&ids))
269291
require.NotEmpty(t, ids)
270292

293+
d, err := driver.New(
294+
context.Background(),
295+
os.Stderr,
296+
opts,
297+
)
298+
require.NoError(t, err)
299+
271300
var found []string
272301
for _, id := range ids {
273302
found = append(found, id.ID.String())
@@ -287,6 +316,13 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
287316
require.NoError(t, c.Select("id").All(&ids))
288317
require.NotEmpty(t, ids)
289318

319+
d, err := driver.New(
320+
context.Background(),
321+
os.Stderr,
322+
opts,
323+
)
324+
require.NoError(t, err)
325+
290326
var found []string
291327
for _, id := range ids {
292328
found = append(found, id.ID.String())
@@ -306,6 +342,13 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
306342
require.NoError(t, c.Select("id").All(&ids))
307343
require.NotEmpty(t, ids)
308344

345+
d, err := driver.New(
346+
context.Background(),
347+
os.Stderr,
348+
opts,
349+
)
350+
require.NoError(t, err)
351+
309352
var found []string
310353
for _, id := range ids {
311354
found = append(found, id.ID.String())
@@ -325,6 +368,13 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
325368
require.NoError(t, c.Select("id").All(&ids))
326369
require.NotEmpty(t, ids)
327370

371+
d, err := driver.New(
372+
context.Background(),
373+
os.Stderr,
374+
opts,
375+
)
376+
require.NoError(t, err)
377+
328378
var found []string
329379
for _, id := range ids {
330380
found = append(found, id.ID.String())
@@ -408,6 +458,13 @@ func testDatabase(t *testing.T, db string, c *pop.Connection) {
408458
t.Parallel()
409459
wg.Wait()
410460

461+
d, err := driver.New(
462+
context.Background(),
463+
os.Stderr,
464+
opts,
465+
)
466+
require.NoError(t, err)
467+
411468
sr, err := d.SettingsFlowPersister().GetSettingsFlow(context.Background(), x.ParseUUID("a79bfcf1-68ae-49de-8b23-4f96921b8341"))
412469
require.NoError(t, err)
413470

schema/handler_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ func TestHandler(t *testing.T) {
135135

136136
for id, s := range schemas {
137137
t.Run(fmt.Sprintf("case=get %s schema", id), func(t *testing.T) {
138-
t.Parallel()
139138

140139
_, err := s.getRaw()
141140
actual := getReq(t.Context(), t, fmt.Sprintf("/schemas/%s", url.PathEscape(id)), s.expectedHttpResponseCode)

0 commit comments

Comments
 (0)