-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_utils.go
37 lines (31 loc) · 1006 Bytes
/
test_utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package neo4j
import (
"context"
"fmt"
. "github.com/onsi/gomega"
"github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait"
)
const username = "neo4j"
const pwd = "password"
const uri = "neo4j://34.213.163.7"
const port = 7687
const db = "neo4j"
type CloseWithContext interface {
Close(context.Context) error
}
func Close(closer CloseWithContext, ctx context.Context, resourceName string) {
Expect(closer.Close(ctx)).To(BeNil(), "%s should be closed", resourceName)
}
func startContainer(ctx context.Context, user, pwd string) (testcontainers.Container, error) {
request := testcontainers.ContainerRequest{
Image: "neo4j:latest",
ExposedPorts: []string{"7687/tcp"},
Env: map[string]string{"NEO4J_AUTH": fmt.Sprintf("%s/%s", user, pwd)},
WaitingFor: wait.ForLog("Bolt enabled"),
}
return testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
ContainerRequest: request,
Started: true,
})
}