test: MongoDB normalizeConfig aliases — close coverage gap from #482#506
test: MongoDB normalizeConfig aliases — close coverage gap from #482#506anandgupta42 wants to merge 1 commit intomainfrom
Conversation
The MongoDB driver was added in #482 but driver-normalize.test.ts had zero tests for the MONGODB_ALIASES map. These 8 tests cover all MongoDB-specific alias normalization paths (connectionString, uri, authSource, replicaSet, directConnection, connectTimeoutMS, mongo type alias, and canonical passthrough). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> https://claude.ai/code/session_01AhNUh22SS3cRR9GVNiTcit
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
📝 WalkthroughWalkthroughA new test suite for MongoDB config normalization was added, covering alias conversion for MongoDB-specific fields (connectionString, authSource, replicaSet, directConnection, connectTimeoutMS) to their snake_case equivalents, and verifying that pre-normalized canonical configs remain unchanged. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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.
🧹 Nitpick comments (1)
packages/opencode/test/altimate/driver-normalize.test.ts (1)
667-747: Consider adding a test forserverSelectionTimeoutMS → server_selection_timeout.
MONGODB_ALIASESalso definesserverSelectionTimeoutMS, and this one is a distinct mapping (not a duplicate-path alias likeuri/url). Adding one test would close the remaining MongoDB-specific alias gap.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/opencode/test/altimate/driver-normalize.test.ts` around lines 667 - 747, Add a test exercising the serverSelectionTimeoutMS → server_selection_timeout alias: call normalizeConfig with { type: "mongodb", serverSelectionTimeoutMS: 30000 } and assert the returned object has server_selection_timeout === 30000 and serverSelectionTimeoutMS is undefined; place this alongside the other MongoDB alias tests in the describe("normalizeConfig — MongoDB") block so the mapping defined in MONGODB_ALIASES is covered.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@packages/opencode/test/altimate/driver-normalize.test.ts`:
- Around line 667-747: Add a test exercising the serverSelectionTimeoutMS →
server_selection_timeout alias: call normalizeConfig with { type: "mongodb",
serverSelectionTimeoutMS: 30000 } and assert the returned object has
server_selection_timeout === 30000 and serverSelectionTimeoutMS is undefined;
place this alongside the other MongoDB alias tests in the
describe("normalizeConfig — MongoDB") block so the mapping defined in
MONGODB_ALIASES is covered.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 85cc108b-3e3f-4ac5-bcd0-4dabc3e13ba1
📒 Files selected for processing (1)
packages/opencode/test/altimate/driver-normalize.test.ts
Deduplicate overlapping tests from PRs #494, #499, #502, #504, #506, #507, #508, #510, #511, #512. Most MongoDB/env-var/dbt coverage was already on main; this adds only genuinely new tests: - SSH tunnel: `extractSshConfig` validation + lifecycle safety (7 tests) - dbt profiles: spark->databricks, trino->postgres adapter mapping - `dbtConnectionsToConfigs` conversion + empty input handling - `containerToConfig` with fully-populated container - MongoDB assertions in `telemetry-safety.test.ts` - Sanity suite: branding, deny, driver, resilience expansions (#494) Closes #513 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Consolidated into #514. This PR's test coverage was either already on main or has been included in the consolidated PR. |
…514) * test: consolidate test coverage from 10 hourly PRs into single PR Deduplicate overlapping tests from PRs #494, #499, #502, #504, #506, #507, #508, #510, #511, #512. Most MongoDB/env-var/dbt coverage was already on main; this adds only genuinely new tests: - SSH tunnel: `extractSshConfig` validation + lifecycle safety (7 tests) - dbt profiles: spark->databricks, trino->postgres adapter mapping - `dbtConnectionsToConfigs` conversion + empty input handling - `containerToConfig` with fully-populated container - MongoDB assertions in `telemetry-safety.test.ts` - Sanity suite: branding, deny, driver, resilience expansions (#494) Closes #513 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address code review findings from 6-model consensus review - Use `require.resolve()` instead of `require()` for driver resolvability checks to avoid false negatives from native binding load failures - Remove unnecessary `altimate_change` markers from new ssh-tunnel test file - Add `closeAllTunnels()` cleanup in `afterEach` to prevent state leaks Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address convergence review findings — driver warns, unshare guard - Driver resolvability checks now emit warnings instead of failures since drivers are intentionally absent from sanity Docker image (#295) - `unshare --net` now tests with a dry-run before use, falling back to proxy-based network blocking when unprivileged (macOS, containers) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
What does this PR do?
1.
normalizeConfig— MongoDB aliases inpackages/drivers/src/normalize.ts(8 new tests)MongoDB driver support was added in #482, but
driver-normalize.test.tshad zero tests for theMONGODB_ALIASESmap. Every other driver (Postgres, Snowflake, BigQuery, Databricks, SQL Server, Oracle, MySQL) had alias normalization tests — MongoDB was the only gap.Why it matters: Users configure MongoDB connections using field names from the MongoDB Node.js driver docs (
connectionString), mongosh docs (uri), or the native driver options (authSource,replicaSet,directConnection,connectTimeoutMS). Without normalization working correctly, these camelCase/alternative names silently fail — the driver doesn't see the connection string and falls back to constructing a URI from host/port, causing connection failures or connecting to the wrong database.Specific scenarios covered:
connectionString→connection_string(MongoDB Node.js driver convention)uri→connection_string(mongosh / pymongo convention)authSource→auth_source(driver option)replicaSet→replica_set(driver option)directConnection→direct_connection(driver option, boolean)connectTimeoutMS→connect_timeout(driver option, number)mongotype alias routes to MongoDB alias map (not justmongodb)What was intentionally excluded (critic review):
username→user,dbname→database) — already tested for other drivers via the sharedCOMMON_ALIASESobjecturl→connection_string— same code path asuri, no additional coveragedetectAuthMethodMongoDB branch — critic analysis showed the branch is shadowed by prior guards; proposed tests would pass for wrong reasonsType of change
Issue for this PR
N/A — proactive test coverage for #482
How did you verify your code works?
Checklist
https://claude.ai/code/session_01AhNUh22SS3cRR9GVNiTcit
Summary by CodeRabbit