chore(surrealdb): use Run function by mdelapenya · Pull Request #3434 · testcontainers/testcontainers-go

Summary by CodeRabbit

  • Refactor
    • Streamlined container startup using composable options for more predictable configuration.
    • Unified environment variable handling to reduce setup side effects and improve reliability.
    • Improved error messages when container startup fails to aid troubleshooting.
    • Preserves existing public APIs; no changes required for current integrations.

Walkthrough

Refactors the SurrealDB module to build container configuration via composable testcontainers.With* options and run containers using testcontainers.Run. Replaces direct request/env mutations with WithEnv wrappers, updates Run to assemble options (ports, wait strategy, cmd), adjusts error messages, and returns a wrapped SurrealDBContainer.

Changes

Cohort / File(s) Summary
SurrealDB module refactor
modules/surrealdb/surrealdb.go
Replace direct env/request mutations with testcontainers.WithEnv and other With* options; refactor Run to assemble moduleOpts and call testcontainers.Run; switch construction to wrap returned container; update error messages; keep public APIs unchanged while altering internal flow.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Caller
  participant Mod as SurrealDB (module)
  participant TC as testcontainers.Run
  participant DK as Docker Engine
  participant C as SurrealDBContainer

  Dev->>Mod: Run(ctx, opts...)
  Mod->>Mod: Build moduleOpts (WithEnv/WithExposedPorts/WithWaitStrategy/WithCmd)
  Mod->>TC: Run(ctx, image, moduleOpts...)
  TC->>DK: Create & start container
  DK-->>TC: Container started / error
  alt success
    TC-->>Mod: Container handle
    Mod->>Mod: Wrap handle as SurrealDBContainer
    Mod-->>Dev: SurrealDBContainer
  else failure
    TC-->>Mod: Error
    Mod-->>Dev: return error ("run surrealdb: ...")
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

I twitch my whiskers, flip and run,
New opts aligned, the work is done.
No more mutating fields by hand—
We stack our Withs, a tidy band.
Hop in a box, then back we come,
Surreal and swift—containers spun! 🐇🧪

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely describes the main change of the pull request, namely switching the SurrealDB module to use the new Run function, and it follows the conventional commit style without extraneous details.
Description Check ✅ Passed The description clearly states what the PR does and why it’s important, and it references the related issue, making it directly relevant to the changes in the pull request.
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

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.