Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add neo4j license agreement customization options #2036

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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