Skip to content

Commit

Permalink
Add neo4j license agreement customization options (#2036)
Browse files Browse the repository at this point in the history
* Add license agreement customization options

* Add test for Neo4j with Enterprise License
  • Loading branch information
danielorbach committed Dec 22, 2023
1 parent 974afd9 commit 1c45958
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
21 changes: 21 additions & 0 deletions modules/neo4j/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,24 @@ func formatNeo4jConfig(name string) string {
result = strings.ReplaceAll(result, ".", "_")
return fmt.Sprintf("NEO4J_%s", result)
}

// WithAcceptCommercialLicenseAgreement sets the environment variable
// NEO4J_ACCEPT_LICENSE_AGREEMENT to "yes", indicating that the user accepts
// the commercial licence agreement of Neo4j Enterprise Edition. The license
// agreement is available at https://neo4j.com/terms/licensing/.
func WithAcceptCommercialLicenseAgreement() testcontainers.CustomizeRequestOption {
return func(req *testcontainers.GenericContainerRequest) {
req.Env["NEO4J_ACCEPT_LICENSE_AGREEMENT"] = "yes"
}
}

// WithAcceptEvaluationLicenseAgreement sets the environment variable
// NEO4J_ACCEPT_LICENSE_AGREEMENT to "eval", indicating that the user accepts
// the evaluation agreement of Neo4j Enterprise Edition. The evaluation
// agreement is available at https://neo4j.com/terms/enterprise_us/. Please
// read the terms of the evaluation agreement before you accept.
func WithAcceptEvaluationLicenseAgreement() testcontainers.CustomizeRequestOption {
return func(req *testcontainers.GenericContainerRequest) {
req.Env["NEO4J_ACCEPT_LICENSE_AGREEMENT"] = "eval"
}
}
39 changes: 39 additions & 0 deletions modules/neo4j/neo4j_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

neo "github.com/neo4j/neo4j-go-driver/v5/neo4j"

"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/modules/neo4j"
)

Expand Down Expand Up @@ -59,6 +60,44 @@ func TestNeo4j(outer *testing.T) {
})
}

func TestNeo4jWithEnterpriseLicense(t *testing.T) {
t.Parallel()

ctx := context.Background()

images := map[string]string{
"StandardEdition": "docker.io/neo4j:4.4",
"EnterpriseEdition": "docker.io/neo4j:4.4-enterprise",
}

for edition, image := range images {
edition, image := edition, image
t.Run(edition, func(t *testing.T) {
t.Parallel()
container, err := neo4j.RunContainer(ctx,
testcontainers.WithImage(image),
neo4j.WithAdminPassword(testPassword),
neo4j.WithAcceptCommercialLicenseAgreement(),
)
if err != nil {
t.Fatalf("expected container to successfully initialize but did not: %s", err)
}

t.Cleanup(func() {
if err := container.Terminate(ctx); err != nil {
t.Fatalf("failed to terminate container: %s", err)
}
})

env := getContainerEnv(t, ctx, container)

if !strings.Contains(env, "NEO4J_ACCEPT_LICENSE_AGREEMENT=yes") {
t.Fatal("expected to accept license agreement but did not")
}
})
}
}

func TestNeo4jWithWrongSettings(outer *testing.T) {
outer.Parallel()

Expand Down

0 comments on commit 1c45958

Please sign in to comment.