Skip to content

test: MongoDB config normalization — alias resolution#496

Closed
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260327-0211
Closed

test: MongoDB config normalization — alias resolution#496
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260327-0211

Conversation

@anandgupta42
Copy link
Contributor

@anandgupta42 anandgupta42 commented Mar 27, 2026

What does this PR do?

1. normalizeConfig() MongoDB aliases — packages/drivers/src/normalize.ts (11 new tests)

MongoDB driver support was added in #482 but the config normalization test file (driver-normalize.test.ts, 61 existing tests covering every other driver) had zero MongoDB coverage. This is a P0 gap: users who provide MongoDB connection config using common field names from MongoDB documentation, dbt profiles, or LLM-generated output would experience silent connection failures because aliases like uri, url, connectionString, authSource, etc. would not be resolved to their canonical snake_case names.

New coverage includes:

  • Connection string aliases: uriconnection_string, urlconnection_string, connectionStringconnection_string
  • Canonical precedence: connection_string takes priority when both canonical and alias fields are present
  • Auth/replica aliases: authSourceauth_source, replicaSetreplica_set
  • Boolean alias: directConnectiondirect_connection
  • Common aliases: usernameuser, dbnamedatabase (shared with other drivers)
  • Type alias: mongo resolves identically to mongodb
  • Timeout aliases: connectTimeoutMSconnect_timeout, serverSelectionTimeoutMSserver_selection_timeout
  • Alias priority ordering: when multiple aliases (connectionString + uri) are both present, the first-listed alias wins per the applyAliases contract

Type of change

  • New feature (non-breaking change which adds functionality)

Issue for this PR

N/A — proactive test coverage for newly added MongoDB driver (#482)

How did you verify your code works?

bun test test/altimate/driver-normalize.test.ts    # 89 pass (72 existing + 11 new + 6 describe groups)

All 89 tests pass. No source code was modified — tests only.

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

https://claude.ai/code/session_01UtQ9rqYTKybuvdu6bM4cTj

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for MongoDB driver configuration handling with comprehensive validation of configuration alias normalization and canonical field mapping. Tests verify proper handling of connection string, authentication, replica set, direct connection, credential, and timeout parameter aliases to ensure consistent configuration normalization.

MongoDB was added in #482 but normalizeConfig() lacked any MongoDB-specific
tests. These 11 tests verify that common field name aliases (uri, url,
connectionString, authSource, replicaSet, directConnection, username, dbname,
timeout fields) are correctly resolved to their canonical snake_case names,
preventing silent connection failures when users provide MongoDB config from
dbt profiles, MongoDB docs, or LLM-generated output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01UtQ9rqYTKybuvdu6bM4cTj
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@coderabbitai
Copy link

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2678429f-1422-4a81-8bce-4fd6de852d83

📥 Commits

Reviewing files that changed from the base of the PR and between abcaa1d and 728feb2.

📒 Files selected for processing (1)
  • packages/opencode/test/altimate/driver-normalize.test.ts

📝 Walkthrough

Walkthrough

Added test suite for normalizeConfig MongoDB aliases, validating that various input aliases (uri, url, connectionString, authSource, replicaSet, directConnection, username, dbname, connectTimeoutMS, serverSelectionTimeoutMS) normalize to their canonical forms with aliases removed.

Changes

Cohort / File(s) Summary
MongoDB Alias Normalization Tests
packages/opencode/test/altimate/driver-normalize.test.ts
New test suite asserting MongoDB-specific alias-to-canonical field mappings (uri/url → connection_string, authSource → auth_source, etc.) and validating that canonical fields take precedence while alias properties are omitted from output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

contributor

Poem

🐰 A tester hops through MongoDB's ways,
Aliases dancing through normalize's maze,
From uri to connection_string they spring,
Each mapping validated—what joy tests bring! 🎉

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding MongoDB config normalization alias resolution tests to the test suite.
Description check ✅ Passed The description comprehensively covers all required template sections with detailed information about what changed, testing verification, and a completed checklist.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/hourly-20260327-0211

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.

anandgupta42 added a commit that referenced this pull request Mar 27, 2026
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>
@anandgupta42
Copy link
Contributor Author

Consolidated into #498. Tests deduplicated and merged into a single PR.

anandgupta42 added a commit that referenced this pull request Mar 27, 2026
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants