From 0e7cb731eb3dc98871901b2a935d0b40103716f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Thu, 25 Apr 2024 20:39:31 +0200 Subject: [PATCH] chore: convert log into error --- modules/neo4j/config.go | 3 +-- modules/neo4j/neo4j_test.go | 20 ++++++-------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/modules/neo4j/config.go b/modules/neo4j/config.go index 02c6afb878..91eb3e415b 100644 --- a/modules/neo4j/config.go +++ b/modules/neo4j/config.go @@ -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}...) diff --git a/modules/neo4j/neo4j_test.go b/modules/neo4j/neo4j_test.go index 4c8413a5f4..23717d4585 100644 --- a/modules/neo4j/neo4j_test.go +++ b/modules/neo4j/neo4j_test.go @@ -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") } })