Skip to content

Commit a1e747c

Browse files
mdelapenyaclaude
andauthored
chore(neo4j): use Run function (#3419)
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <[email protected]>
1 parent c5ace15 commit a1e747c

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

modules/neo4j/neo4j.go

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,50 +37,40 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
3737

3838
// Run creates an instance of the Neo4j container type
3939
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*Neo4jContainer, error) {
40-
request := testcontainers.ContainerRequest{
41-
Image: img,
42-
Env: map[string]string{
40+
moduleOpts := []testcontainers.ContainerCustomizer{
41+
testcontainers.WithEnv(map[string]string{
4342
"NEO4J_AUTH": "none",
44-
},
45-
ExposedPorts: []string{
43+
}),
44+
testcontainers.WithExposedPorts(
4645
defaultBoltPort,
4746
defaultHTTPPort,
4847
defaultHTTPSPort,
49-
},
50-
WaitingFor: &wait.MultiStrategy{
48+
),
49+
testcontainers.WithWaitStrategy(&wait.MultiStrategy{
5150
Strategies: []wait.Strategy{
5251
wait.NewLogStrategy("Bolt enabled on"),
5352
&wait.HTTPStrategy{
5453
Port: defaultHTTPPort,
5554
StatusCodeMatcher: isHTTPOk(),
5655
},
5756
},
58-
},
59-
}
60-
61-
genericContainerReq := testcontainers.GenericContainerRequest{
62-
ContainerRequest: request,
63-
Started: true,
57+
}),
6458
}
6559

6660
if len(opts) == 0 {
6761
opts = append(opts, WithoutAuthentication())
6862
}
6963

70-
for _, option := range opts {
71-
if err := option.Customize(&genericContainerReq); err != nil {
72-
return nil, err
73-
}
74-
}
64+
moduleOpts = append(moduleOpts, opts...)
7565

76-
container, err := testcontainers.GenericContainer(ctx, genericContainerReq)
66+
ctr, err := testcontainers.Run(ctx, img, moduleOpts...)
7767
var c *Neo4jContainer
78-
if container != nil {
79-
c = &Neo4jContainer{Container: container}
68+
if ctr != nil {
69+
c = &Neo4jContainer{Container: ctr}
8070
}
8171

8272
if err != nil {
83-
return c, fmt.Errorf("generic container: %w", err)
73+
return c, fmt.Errorf("run neo4j: %w", err)
8474
}
8575

8676
return c, nil

0 commit comments

Comments
 (0)