Created
November 27, 2020 09:20
-
-
Save fbiville/15050a734802a6374b3d3aafbedbfb55 to your computer and use it in GitHub Desktop.
Medium blogpost code snippet 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ( | |
"context" | |
"fmt" | |
"github.com/testcontainers/testcontainers-go" | |
"github.com/testcontainers/testcontainers-go/wait" | |
) | |
func startContainer(ctx context.Context, username, password string) (testcontainers.Container, error) { | |
request := testcontainers.ContainerRequest{ | |
Image: "neo4j", // get latest Neo4j Docker image | |
ExposedPorts: []string{"7687/tcp"}, // expose only Bolt port | |
Env: map[string]string{"NEO4J_AUTH": fmt.Sprintf("%s/%s", username, password)}, // override default credentials | |
WaitingFor: wait.ForLog("Bolt enabled"), // wait for Bolt | |
} | |
return testcontainers.GenericContainer( | |
ctx, | |
testcontainers.GenericContainerRequest{ | |
ContainerRequest: request, | |
Started: true, // start container immediately | |
}, | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment