test: MongoDB driver — normalization aliases + auth method detection#499
test: MongoDB driver — normalization aliases + auth method detection#499anandgupta42 wants to merge 1 commit intomainfrom
Conversation
Cover the MongoDB aliases added in #482 and the MongoDB-specific branch in detectAuthMethod. Without these tests, camelCase config field names from LLMs or dbt profiles (connectionString, authSource, replicaSet) could silently fail to normalize, preventing MongoDB connections. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
📝 WalkthroughWalkthroughTwo test files were enhanced with new MongoDB-specific test cases. The first covers alias normalization for various camelCase and alternative field names mapping to snake_case canonical forms, plus type alias resolution and field precedence. The second verifies auth method detection for MongoDB driver types without passwords. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested labels
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)
773-776: Consider removing the orphaned section header above the MongoDB block.The insertion of the MongoDB test section left an orphaned "Snowflake private_key edge cases" comment block at lines 651-654 (the original header). This new header at lines 773-775 correctly labels the Snowflake test block at line 777, making the original header at 651-654 redundant and potentially confusing since it now appears directly before the MongoDB section.
🔧 Remove orphaned header (outside this line range)
Remove lines 651-654 to eliminate the duplicate/orphaned section header:
}) -// --------------------------------------------------------------------------- -// normalizeConfig — Snowflake private_key edge cases -// --------------------------------------------------------------------------- - // --------------------------------------------------------------------------- // normalizeConfig — MongoDB aliases // ---------------------------------------------------------------------------🤖 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 773 - 776, Remove the orphaned section header "normalizeConfig — Snowflake private_key edge cases" that was left before the MongoDB tests; locate the duplicate comment block with that exact text and delete it so only the correct Snowflake header (the one immediately before the Snowflake tests) remains, preventing confusion between the MongoDB and Snowflake sections.
🤖 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 773-776: Remove the orphaned section header "normalizeConfig —
Snowflake private_key edge cases" that was left before the MongoDB tests; locate
the duplicate comment block with that exact text and delete it so only the
correct Snowflake header (the one immediately before the Snowflake tests)
remains, preventing confusion between the MongoDB and Snowflake sections.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 134cc591-36f0-476d-994f-5bed196f3804
📒 Files selected for processing (2)
packages/opencode/test/altimate/driver-normalize.test.tspackages/opencode/test/altimate/warehouse-telemetry.test.ts
What does this PR do?
Adds missing test coverage for the MongoDB driver support introduced in #482. The existing
driver-normalize.test.tscovered every warehouse driver's aliases except MongoDB, andwarehouse-telemetry.test.tstesteddetectAuthMethodfor every driver type except MongoDB.1.
normalizeConfig— MongoDB aliases —packages/drivers/src/normalize.ts(12 new tests)The normalize module resolves camelCase and SDK-style field names to canonical snake_case before configs reach the driver. MongoDB was added to the alias map in #482 but had zero test coverage. If an LLM or dbt profile passes
connectionString,authSource,replicaSet, etc., normalization must work correctly or the user silently fails to connect. New coverage includes:connectionString→connection_stringuri→connection_stringurl→connection_stringauthSource→auth_sourcereplicaSet→replica_setdirectConnection→direct_connectionconnectTimeoutMS→connect_timeoutserverSelectionTimeoutMS→server_selection_timeout"mongo"type alias resolves MongoDB aliases correctlyconnection_stringtakes precedence overurialias (first-value-wins)2.
detectAuthMethod— MongoDB branch —src/altimate/native/connections/registry.ts(2 new tests)The MongoDB-specific auth detection branch (line 229) defaults to
"connection_string"when no password is present — the typical MongoDB auth pattern. This branch was unreachable by existing tests which all usedunsupported_db_type. Coverage includes:{ type: "mongodb", host: "localhost" }→"connection_string"(not"unknown"){ type: "mongo", host: "localhost" }→"connection_string"(type alias)Type of change
Issue for this PR
N/A — proactive test coverage for new MongoDB driver (#482)
How did you verify your code works?
Checklist
Summary by CodeRabbit
Note: This release contains internal test improvements with no user-visible changes.