Skip to content

Commit

Permalink
fix: set config at the start
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Jan 12, 2023
1 parent e8e8ce5 commit e58bc6e
Showing 1 changed file with 32 additions and 36 deletions.
68 changes: 32 additions & 36 deletions identity/test/pool.go
Expand Up @@ -45,21 +45,41 @@ func TestPool(ctx context.Context, conf *config.Config, p interface {
persistence.Persister
}, m *identity.Manager) func(t *testing.T) {
return func(t *testing.T) {
exampleServerURL := urlx.ParseOrPanic("http://example.com")
conf.MustSet(ctx, config.ViperKeyPublicBaseURL, exampleServerURL.String())

nid, p := testhelpers.NewNetworkUnlessExisting(t, ctx, p)
expandSchema := schema.Schema{
ID: "expandSchema",
URL: urlx.ParseOrPanic("file://./stub/expand.schema.json"),
RawURL: "file://./stub/expand.schema.json",
}
defaultSchema := schema.Schema{
ID: config.DefaultIdentityTraitsSchemaID,
URL: urlx.ParseOrPanic("file://./stub/identity.schema.json"),
RawURL: "file://./stub/identity.schema.json",
}
altSchema := schema.Schema{
ID: "altSchema",
URL: urlx.ParseOrPanic("file://./stub/identity-2.schema.json"),
RawURL: "file://./stub/identity-2.schema.json",
}
conf.MustSet(ctx, config.ViperKeyIdentitySchemas, []config.Schema{
{
ID: altSchema.ID,
URL: altSchema.RawURL,
},
{
ID: defaultSchema.ID,
URL: defaultSchema.RawURL,
},
{
ID: expandSchema.ID,
URL: expandSchema.RawURL,
},
})

t.Run("case=expand", func(t *testing.T) {
expandSchema := schema.Schema{
ID: "expandSchema",
URL: urlx.ParseOrPanic("file://./stub/expand.schema.json"),
RawURL: "file://./stub/expand.schema.json",
}

conf.MustSet(ctx, config.ViperKeyIdentitySchemas, []config.Schema{
{
ID: expandSchema.ID,
URL: expandSchema.RawURL,
},
})

require.NoError(t, p.GetConnection(ctx).RawQuery("DELETE FROM identities WHERE nid = ?", nid).Exec())
t.Cleanup(func() {
Expand Down Expand Up @@ -194,31 +214,7 @@ func TestPool(ctx context.Context, conf *config.Config, p interface {
})
})

exampleServerURL := urlx.ParseOrPanic("http://example.com")
conf.MustSet(ctx, config.ViperKeyPublicBaseURL, exampleServerURL.String())
defaultSchema := schema.Schema{
ID: config.DefaultIdentityTraitsSchemaID,
URL: urlx.ParseOrPanic("file://./stub/identity.schema.json"),
RawURL: "file://./stub/identity.schema.json",
}
altSchema := schema.Schema{
ID: "altSchema",
URL: urlx.ParseOrPanic("file://./stub/identity-2.schema.json"),
RawURL: "file://./stub/identity-2.schema.json",
}
conf.MustSet(ctx, config.ViperKeyIdentitySchemas, []config.Schema{
{
ID: altSchema.ID,
URL: altSchema.RawURL,
},
{
ID: defaultSchema.ID,
URL: defaultSchema.RawURL,
},
})

var createdIDs []uuid.UUID

var passwordIdentity = func(schemaID string, credentialsID string) *identity.Identity {
i := identity.NewIdentity(schemaID)
i.SetCredentials(identity.CredentialsTypePassword, identity.Credentials{
Expand Down

0 comments on commit e58bc6e

Please sign in to comment.