Skip to content

Conversation

@mdelapenya
Copy link
Member

What does this PR do?

Use the Run function in neo4j module

Why is it important?

Migrate modules to the new API, improving consistency and leveraging the latest testcontainers functionality.

Related issues

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@mdelapenya mdelapenya requested a review from a team as a code owner October 7, 2025 12:30
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Oct 7, 2025
@netlify
Copy link

netlify bot commented Oct 7, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 2ba29cf
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/68e507df4e83170008c76208
😎 Deploy Preview https://deploy-preview-3419--testcontainers-go.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Summary by CodeRabbit

  • Refactor
    • Modernized Neo4j container setup to an option-driven approach for cleaner, more modular configuration while preserving existing behavior (including default authentication handling).
  • Chores
    • Standardized error message wording during Neo4j startup for clearer diagnostics.

No user-facing changes; functionality remains the same.

Walkthrough

Refactors Neo4j module container setup to use an option-based testcontainers.Run API. Builds a moduleOpts slice with environment, ports, and wait strategy, appends user opts, and runs the container. Replaces GenericContainer/ContainerRequest usage and updates error wording. No exported API changes.

Changes

Cohort / File(s) Summary
Neo4j module: migrate to Run API
modules/neo4j/neo4j.go
Replace GenericContainerRequest/GenericContainer with option-based testcontainers.Run; assemble moduleOpts via WithEnv, WithExposedPorts, WithWaitStrategy; append provided opts; update variable names; adjust error message to "run neo4j: %w"; preserve default auth behavior via WithoutAuthentication().

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor Caller
    participant Neo4jModule as Neo4j Module
    participant TC as testcontainers.Run
    participant Ctr as Container

    Caller->>Neo4jModule: Run(ctx, opts...)
    Neo4jModule->>Neo4jModule: Build moduleOpts\n(WithEnv, WithExposedPorts,\nWithWaitStrategy)
    Neo4jModule->>Neo4jModule: Append opts...
    Neo4jModule->>TC: Run(ctx, moduleOpts...)
    alt success
        TC-->>Neo4jModule: ctr
        Neo4jModule->>Neo4jModule: Wrap into Neo4jContainer
        Neo4jModule-->>Caller: Neo4jContainer
    else error
        TC-->>Neo4jModule: error
        Note right of Neo4jModule: return "run neo4j: %w"
        Neo4jModule-->>Caller: error
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

A hop, a skip, I tweak the run,
Options lined like carrots in the sun.
No crates to craft, just opts to spin—
Ports exposed, waits begin.
With whiskers twitching, logs unwind—
Neo4j’s up; I’m outta thyme. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title follows conventional commit style and succinctly captures the main change of updating the neo4j module to use the Run function, making it clear and directly related to the changeset.
Description Check ✅ Passed The description clearly states what the PR does, explains its importance in migrating to the new API, and references related work, all of which align with the changes in the neo4j module.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0404be and 2ba29cf.

📒 Files selected for processing (1)
  • modules/neo4j/neo4j.go (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
modules/neo4j/neo4j.go (5)
options.go (4)
  • ContainerCustomizer (22-24)
  • WithEnv (75-85)
  • WithExposedPorts (454-459)
  • WithWaitStrategy (366-368)
wait/all.go (1)
  • MultiStrategy (16-23)
wait/log.go (1)
  • NewLogStrategy (59-66)
wait/http.go (1)
  • HTTPStrategy (26-45)
modules/neo4j/config.go (1)
  • WithoutAuthentication (26-28)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test (1.24.x, modules/neo4j) / test: modules/neo4j/1.24.x
  • GitHub Check: test (1.25.x, modules/neo4j) / test: modules/neo4j/1.25.x
  • GitHub Check: Analyze (go)
🔇 Additional comments (4)
modules/neo4j/neo4j.go (4)

40-58: LGTM! Clean refactoring to option-based approach.

The refactoring successfully adopts the new testcontainers.Run API with a modular, option-based approach. The moduleOpts construction is clear and maintainable, properly setting up environment variables, exposed ports, and wait strategies.

Based on learnings: This follows the recommended pattern for testcontainers-go modules, using ContainerCustomizer options to encapsulate sensible defaults.


60-64: LGTM! Proper option ordering and backward compatibility.

The logic correctly maintains backward compatibility by applying WithoutAuthentication() when no user options are provided, and properly appends user options after module defaults, allowing users to override defaults if needed.


66-66: LGTM! Proper migration to the new Run API.

The migration from testcontainers.GenericContainer to testcontainers.Run correctly adopts the new API pattern, which is the recommended approach for testcontainers-go modules.

Based on learnings: The Run function encapsulates sensible defaults and cleanup, making it the preferred API for module implementations.


68-74: LGTM! Robust error handling with improved messaging.

The defensive nil check (line 68) and construction of Neo4jContainer even when errors occur enables proper cleanup. The updated error message "run neo4j: %w" is more specific and accurately reflects the new API usage.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mdelapenya mdelapenya self-assigned this Oct 7, 2025
@mdelapenya mdelapenya merged commit a1e747c into testcontainers:main Oct 7, 2025
17 checks passed
@mdelapenya mdelapenya deleted the use-run-claude-neo4j branch October 7, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore Changes that do not impact the existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant