Skip to content

Commit

Permalink
chore: convert log into error
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelapenya committed Apr 25, 2024
1 parent 70f1eac commit 0e7cb73
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
3 changes: 1 addition & 2 deletions modules/neo4j/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ func addSetting(req *testcontainers.GenericContainerRequest, key string, newVal
if oldVal, found := req.Env[normalizedKey]; found {
// make sure AUTH is not overwritten by a setting
if key == "AUTH" {
req.Logger.Printf("setting %q is not permitted, WithAdminPassword has already been set\n", normalizedKey)
return nil
return fmt.Errorf("setting %q is not permitted, WithAdminPassword has already been set", normalizedKey)
}

req.Logger.Printf("setting %q with value %q is now overwritten with value %q\n", []any{key, oldVal, newVal}...)
Expand Down
20 changes: 6 additions & 14 deletions modules/neo4j/neo4j_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,24 +115,16 @@ func TestNeo4jWithWrongSettings(outer *testing.T) {
})
})

outer.Run("ignores auth setting outside WithAdminPassword", func(t *testing.T) {
outer.Run("auth setting outside WithAdminPassword raises error", func(t *testing.T) {
container, err := neo4j.RunContainer(ctx,
neo4j.WithAdminPassword(testPassword),
neo4j.WithNeo4jSetting("AUTH", "neo4j/thisisgonnabeignored"),
neo4j.WithNeo4jSetting("AUTH", "neo4j/thisisgonnafail"),
)
if err != nil {
t.Fatalf("expected env to successfully run but did not: %s", err)
if err == nil {
t.Fatalf("expected env to fail due to conflicting auth settings but did not")
}
t.Cleanup(func() {
if err := container.Terminate(ctx); err != nil {
outer.Fatalf("failed to terminate container: %s", err)
}
})

env := getContainerEnv(t, ctx, container)

if !strings.Contains(env, "NEO4J_AUTH=neo4j/"+testPassword) {
t.Fatalf("expected WithAdminPassword to have higher precedence than auth set with WithNeo4jSetting")
if container != nil {
t.Fatalf("container must not be created with conflicting auth settings")
}
})

Expand Down

0 comments on commit 0e7cb73

Please sign in to comment.