Skip to content

Conversation

@mdelapenya
Copy link
Member

What does this PR do?

Use Run function in the Couchbase module

Why is it important?

Migrate modules to the new API

Related issues

@mdelapenya mdelapenya requested a review from a team as a code owner October 2, 2025 09:12
@mdelapenya mdelapenya added the chore Changes that do not impact the existing functionality label Oct 2, 2025
@mdelapenya mdelapenya self-assigned this Oct 2, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 2, 2025

Summary by CodeRabbit

  • Refactor
    • Updated Couchbase container public API to use a named container field, which may require minor integration changes.
    • Switched to an option-based initialization flow for configuring exposed ports and per-service settings.
    • Improved error messaging when starting the container.

Walkthrough

Refactors Couchbase module to replace anonymous embedding of testcontainers.Container with a named Container field and migrates container startup from GenericContainerRequest to testcontainers.Run using container customizers. Updates initialization to set Container: ctr and wraps run errors with fmt.Errorf("run couchbase: %w", err).

Changes

Cohort / File(s) Summary of Changes
Couchbase module refactor
modules/couchbase/couchbase.go
- Change struct: anonymous testcontainers.Container -> named Container testcontainers.Container.
- Replace GenericContainerRequest flow with building moduleOpts (container customizers) and calling testcontainers.Run(ctx, moduleOpts...) merged with provided opts.
- Configure exposed ports via WithExposedPorts in moduleOpts and propagate per-service customizers into the run options.
- Assign returned container to CouchbaseContainer.Container when non-nil.
- Wrap run errors using fmt.Errorf("run couchbase: %w", err).
- Preserve existing credential/config validation and bucket handling, applied via the new customizer-based flow.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant CouchbaseModule
  participant Testcontainers

  Caller->>CouchbaseModule: Run(ctx, opts...)
  CouchbaseModule->>CouchbaseModule: build moduleOpts (WithExposedPorts, env, wait, service customizers)
  CouchbaseModule->>Testcontainers: Run(ctx, moduleOpts + opts)
  alt success
    Testcontainers-->>CouchbaseModule: container (ctr)
    CouchbaseModule->>CouchbaseModule: CouchbaseContainer.Container = ctr
    CouchbaseModule-->>Caller: CouchbaseContainer
  else failure
    Testcontainers-->>CouchbaseModule: err
    CouchbaseModule-->>Caller: fmt.Errorf("run couchbase: %w", err)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I nibble code beneath the log,
From hidden fields to named-on-frog.
I stitch the opts, I call the run,
Wrap errors tight when push is done.
A tiny hop — the changes cheer, hooray! 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title succinctly describes the main change—switching the Couchbase module to use the Run function—reflecting the core update without extraneous details.
Description Check ✅ Passed The description clearly states that the pull request updates the Couchbase module to use the Run function and explains why the change is needed, linking it to API migration, which aligns with the actual changes.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • 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 f8030a0 and 4940f14.

📒 Files selected for processing (1)
  • modules/couchbase/couchbase.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
modules/couchbase/couchbase.go (2)
options.go (2)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
modules/consul/consul.go (1)
  • Run (61-83)
🔇 Additional comments (1)
modules/couchbase/couchbase.go (1)

79-109: Nice defensive copy of caller opts.

Building serviceCustomizers separately keeps the caller-provided slice untouched while still funneling defaults through config and module opts. Good safeguard against slice aliasing surprises.


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.

@netlify
Copy link

netlify bot commented Oct 2, 2025

Deploy Preview for testcontainers-go ready!

Name Link
🔨 Latest commit 4940f14
🔍 Latest deploy log https://app.netlify.com/projects/testcontainers-go/deploys/68de470ef40535000815984f
😎 Deploy Preview https://deploy-preview-3401--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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e3c6250 and f8030a0.

📒 Files selected for processing (1)
  • modules/couchbase/couchbase.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
modules/couchbase/couchbase.go (2)
options.go (2)
  • ContainerCustomizer (22-24)
  • WithExposedPorts (454-459)
modules/consul/consul.go (1)
  • Run (61-83)

@mdelapenya mdelapenya merged commit bcdb24f into testcontainers:main Oct 2, 2025
17 checks passed
@mdelapenya mdelapenya deleted the use-run-couchbase branch October 2, 2025 10:36
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