test: MongoDB config normalization aliases — 13 new tests#484
test: MongoDB config normalization aliases — 13 new tests#484anandgupta42 wants to merge 1 commit intomainfrom
Conversation
MongoDB driver was added in PR #482 but its config alias normalization had zero unit test coverage. These tests ensure camelCase config keys (connectionString, uri, authSource, replicaSet, etc.) resolve correctly, preventing silent connection failures for users providing non-canonical config field names. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> https://claude.ai/code/session_019D8HyMGHH3Pf43PddTqUw5
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.
Tip: disable this comment in your organization's Code Review settings.
📝 WalkthroughWalkthroughA new MongoDB-specific configuration alias normalization test suite was added, covering field mappings such as Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 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)
693-709: Consider pinning alias-order behavior when bothuriandurlare present.You already test canonical-over-alias precedence. Adding one case with both non-canonical aliases would lock in the current first-alias-wins order and prevent future regressions in alias-list ordering.
Proposed additional test
describe("normalizeConfig — MongoDB", () => { + test("uri takes precedence over url when both aliases are present", () => { + const result = normalizeConfig({ + type: "mongodb", + uri: "mongodb://uri-first:27017/db", + url: "mongodb://url-second:27017/db", + }) + expect(result.connection_string).toBe("mongodb://uri-first:27017/db") + expect(result.uri).toBeUndefined() + expect(result.url).toBeUndefined() + }) + test("canonical mongodb config passes through unchanged", () => {Also applies to: 711-719
🤖 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 693 - 709, Add a test to pin current alias-resolution order when both non-canonical aliases are present: call normalizeConfig with both uri and url set (e.g., uri first, url second) and assert that connection_string equals the first alias value and the second alias is undefined; use a clear test name like "uri+url → first-alias-wins" referencing normalizeConfig so future changes to alias ordering will fail the test if behavior changes.
🤖 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 693-709: Add a test to pin current alias-resolution order when
both non-canonical aliases are present: call normalizeConfig with both uri and
url set (e.g., uri first, url second) and assert that connection_string equals
the first alias value and the second alias is undefined; use a clear test name
like "uri+url → first-alias-wins" referencing normalizeConfig so future changes
to alias ordering will fail the test if behavior changes.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a5339c36-4ff2-40a3-835f-b194ce636097
📒 Files selected for processing (1)
packages/opencode/test/altimate/driver-normalize.test.ts
Consolidates tests from PRs #440, #441, #479, #483, #484, #485, #490, #491, #492, #495, #496. Deduplicates overlapping MongoDB normalize tests (3 PRs → 1), `keybind` tests (2 PRs → 1), and `connections.test.ts` additions (4 PRs → 1 merged file). New test files: - `sql-analyze-tool.test.ts` — `SqlAnalyzeTool` formatting (6 tests) - `sql-analyze-format.test.ts` — `sql.analyze` success semantics + dispatcher (5 tests) - `builtin-commands.test.ts` — altimate builtin command registration (10 tests) - `hints-discover-mcps.test.ts` — `Command.hints()` + discover-and-add-mcps (11 tests) - `fingerprint-detect.test.ts` — file-based project detection rules (11 tests) - `dbt-lineage-helpers.test.ts` — dbt lineage helper functions (13 tests) - `registry-env-loading.test.ts` — `ALTIMATE_CODE_CONN_*` env var loading (8 tests) - `warehouse-telemetry.test.ts` — MongoDB auth detection telemetry (4 tests) - `bus-event.test.ts` — bus event registry payloads (5 tests) - `git.test.ts` — git utility functions (5 tests) - `keybind.test.ts` — keybind parsing, matching, `fromParsedKey` (22 tests) Merged into existing files: - `connections.test.ts` — `loadFromEnv` (5), `detectAuthMethod` (14), credential stripping (1), `containerToConfig` (1), dbt profiles edge cases (3) - `driver-normalize.test.ts` — MongoDB alias resolution (13 tests) Fixes: - `fixture.ts` — disable `commit.gpgsign` in test tmpdir to prevent CI failures - `hints-discover-mcps.test.ts` — corrected sort order expectation - `registry-env-loading.test.ts` — fixed flaky assertion that assumed isolated env Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Consolidated into #498. Tests deduplicated and merged into a single PR. |
* test: consolidate 11 test PRs into single suite — 305 new tests Consolidates tests from PRs #440, #441, #479, #483, #484, #485, #490, #491, #492, #495, #496. Deduplicates overlapping MongoDB normalize tests (3 PRs → 1), `keybind` tests (2 PRs → 1), and `connections.test.ts` additions (4 PRs → 1 merged file). New test files: - `sql-analyze-tool.test.ts` — `SqlAnalyzeTool` formatting (6 tests) - `sql-analyze-format.test.ts` — `sql.analyze` success semantics + dispatcher (5 tests) - `builtin-commands.test.ts` — altimate builtin command registration (10 tests) - `hints-discover-mcps.test.ts` — `Command.hints()` + discover-and-add-mcps (11 tests) - `fingerprint-detect.test.ts` — file-based project detection rules (11 tests) - `dbt-lineage-helpers.test.ts` — dbt lineage helper functions (13 tests) - `registry-env-loading.test.ts` — `ALTIMATE_CODE_CONN_*` env var loading (8 tests) - `warehouse-telemetry.test.ts` — MongoDB auth detection telemetry (4 tests) - `bus-event.test.ts` — bus event registry payloads (5 tests) - `git.test.ts` — git utility functions (5 tests) - `keybind.test.ts` — keybind parsing, matching, `fromParsedKey` (22 tests) Merged into existing files: - `connections.test.ts` — `loadFromEnv` (5), `detectAuthMethod` (14), credential stripping (1), `containerToConfig` (1), dbt profiles edge cases (3) - `driver-normalize.test.ts` — MongoDB alias resolution (13 tests) Fixes: - `fixture.ts` — disable `commit.gpgsign` in test tmpdir to prevent CI failures - `hints-discover-mcps.test.ts` — corrected sort order expectation - `registry-env-loading.test.ts` — fixed flaky assertion that assumed isolated env Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: address CodeRabbit review comments - `bus-event.test.ts`: move `BusEvent.define` into tests instead of module scope - `builtin-commands.test.ts`: fix misleading "lexicographic" → "numeric" sort label - `git.test.ts`: use `tmpdir({ git: true })` fixture instead of manual `git init` - `registry-env-loading.test.ts`: remove unused `fs`, `os`, `path` imports 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 —packages/drivers/src/normalize.ts(13 new tests)MongoDB was added as the 11th supported driver in PR #482 (commit
abcaa1d), but the config normalization alias map (MONGODB_ALIASES) had zero unit test coverage. Every other driver (Snowflake, BigQuery, Databricks, Postgres, Redshift, MySQL, SQL Server, Oracle, DuckDB, SQLite) already had dedicated normalization tests indriver-normalize.test.ts.Why this matters: Users providing MongoDB configs via dbt profiles, LLM-generated configs, or SDK conventions use camelCase keys (
connectionString,authSource,replicaSet,directConnection). Without normalization, these keys silently pass through unresolved, causing connection failures with no clear error message. Themongotype alias (shorthand formongodb) was also untested.Specific scenarios covered:
connectionString,uri,url→connection_string(3 tests)connection_stringtakes priority overurialias (1 test)authSource→auth_source,replicaSet→replica_set,directConnection→direct_connection,connectTimeoutMS→connect_timeout,serverSelectionTimeoutMS→server_selection_timeout(5 tests)username→user,dbname→database(2 tests)mongoresolves to the same alias map asmongodb(1 test)Test quality: All tests are pure-function unit tests with no network, timing, or filesystem dependencies. Reviewed and approved by a critic agent before committing.
Type of change
Issue for this PR
N/A — proactive test coverage for newly added MongoDB driver
How did you verify your code works?
Checklist
https://claude.ai/code/session_019D8HyMGHH3Pf43PddTqUw5
Summary by CodeRabbit