-
-
Notifications
You must be signed in to change notification settings - Fork 583
chore(surrealdb): use Run function #3434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(surrealdb): use Run function #3434
Conversation
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Summary by CodeRabbit
WalkthroughRefactors 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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
🧹 Nitpick comments (1)
modules/surrealdb/surrealdb.go (1)
29-63: Consider simplifying WithXXX functions to avoid double indirection.Each function creates a wrapper that immediately invokes
testcontainers.WithEnv. SinceWithEnvalready returns aCustomizeRequestOption, the extra wrapper is redundant.For example,
WithUsernamecan be simplified to:func WithUsername(username string) testcontainers.CustomizeRequestOption { - return func(req *testcontainers.GenericContainerRequest) error { - return testcontainers.WithEnv(map[string]string{"SURREAL_USER": username})(req) - } + return testcontainers.WithEnv(map[string]string{"SURREAL_USER": username}) }Apply the same pattern to
WithPassword,WithAuthentication,WithStrictMode, andWithAllowAllCaps.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
modules/surrealdb/surrealdb.go(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
modules/surrealdb/surrealdb.go (3)
options.go (6)
WithEnv(75-85)CustomizeRequestOption(28-28)ContainerCustomizer(22-24)WithExposedPorts(454-459)WithWaitStrategy(366-368)WithCmd(462-467)generic.go (1)
GenericContainerRequest(21-27)wait/log.go (1)
ForLog(118-120)
⏰ 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/surrealdb) / test: modules/surrealdb/1.24.x
- GitHub Check: test (1.25.x, modules/surrealdb) / test: modules/surrealdb/1.25.x
- GitHub Check: Analyze (go)
🔇 Additional comments (1)
modules/surrealdb/surrealdb.go (1)
72-98: LGTM! Well-structured refactoring to composable options.The refactoring correctly implements the composable options pattern:
- Default configuration built via
moduleOptsslice- Uses standard testcontainers options (WithEnv, WithExposedPorts, WithWaitStrategy, WithCmd)
- Properly combines module defaults with user-provided options
- Error handling correctly wraps container even on error (enables cleanup)
- Maintains backward compatibility with existing public API
What does this PR do?
Use the Run function in surrealdb
Why is it important?
Migrate modules to the new API, improving consistency and leveraging the latest testcontainers functionality.
Related issues