test: project-scan — ClickHouse env var detection and DATABASE_URL scheme parsing#620
test: project-scan — ClickHouse env var detection and DATABASE_URL scheme parsing#620anandgupta42 wants to merge 1 commit intomainfrom
Conversation
…heme parsing Add 4 tests for the ClickHouse env var detection added in PR #574 but never tested. Update clearWarehouseEnvVars() helper to also clear CLICKHOUSE_* vars for test isolation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> https://claude.ai/code/session_014pS7RRkb53MH36pc6qhSBT
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.
📝 WalkthroughWalkthroughThe test suite for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 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/tool/project-scan.test.ts (1)
550-561: Consider addingconnection_stringmasking assertion for consistency.The
clickhouse+http/clickhouse+httpstest validatestypeandsignalbut doesn't assertconnection_stringmasking like theclickhouse://scheme test does (line 547). This is optional since the masking behavior is uniform across allDATABASE_URLpaths, but adding it would make the test more complete.💡 Optional enhancement
const ch = result.find((r) => r.type === "clickhouse") expect(ch).toBeDefined() expect(ch!.signal).toBe("DATABASE_URL") expect(ch!.type).toBe("clickhouse") + expect(ch!.config.connection_string).toBe("***") }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/opencode/test/tool/project-scan.test.ts` around lines 550 - 561, The test "detects ClickHouse via DATABASE_URL with clickhouse+http and clickhouse+https schemes" checks type and signal but omits asserting the masked connection string; update the loop in that test to also assert the masked connection string returned by detectEnvVars: after finding ch (const ch = result.find((r) => r.type === "clickhouse")), add an expectation like expect(ch!.connection_string).toBe(`${scheme}://default:***@clickhouse.example.com:8443/analytics`) so the masking behavior for clickhouse+http and clickhouse+https matches the existing clickhouse:// test.
🤖 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/tool/project-scan.test.ts`:
- Around line 550-561: The test "detects ClickHouse via DATABASE_URL with
clickhouse+http and clickhouse+https schemes" checks type and signal but omits
asserting the masked connection string; update the loop in that test to also
assert the masked connection string returned by detectEnvVars: after finding ch
(const ch = result.find((r) => r.type === "clickhouse")), add an expectation
like
expect(ch!.connection_string).toBe(`${scheme}://default:***@clickhouse.example.com:8443/analytics`)
so the masking behavior for clickhouse+http and clickhouse+https matches the
existing clickhouse:// test.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6d67e099-ebd6-4af2-ab3f-6578e069d12e
📒 Files selected for processing (1)
packages/opencode/test/tool/project-scan.test.ts
❌ Tests — Failures DetectedTypeScript — 15 failure(s)
cc @anandgupta42 |
Summary
detectEnvVars()—src/altimate/tools/project-scan.ts(4 new tests)The ClickHouse warehouse driver was added in PR #574, which included new env var detection entries (
CLICKHOUSE_HOST,CLICKHOUSE_URL) and newDATABASE_URLscheme mappings (clickhouse://,clickhouse+http://,clickhouse+https://) indetectEnvVars(). However, no tests were added for these code paths. All other warehouse types (Snowflake, BigQuery, Databricks, Postgres, MySQL, Redshift) had detection tests — ClickHouse was the only gap.Why it matters: Without these tests, a regression that removes or breaks the ClickHouse entries in
detectEnvVars()would go undetected. Users withCLICKHOUSE_HOSTorDATABASE_URL=clickhouse://...set would get no auto-detection duringproject_scan, breaking the "just works" onboarding experience. TheDATABASE_URLscheme tests are especially important because a missing scheme entry silently falls through to the"postgres"default — a silent misclassification.Specific scenarios covered:
CLICKHOUSE_HOSTwith full config (host, port, database, user, password masking)CLICKHOUSE_URL(connection_string signal path)DATABASE_URLwithclickhouse://scheme → correctly classified asclickhouse(notpostgres)DATABASE_URLwithclickhouse+http://andclickhouse+https://schemes → both classified asclickhouseAlso fixed: Updated
clearWarehouseEnvVars()test helper to clear all 8CLICKHOUSE_*env vars, ensuring test isolation.Type of change
Issue for this PR
N/A — proactive test coverage for ClickHouse driver added in #574
How did you verify your code works?
Checklist
https://claude.ai/code/session_014pS7RRkb53MH36pc6qhSBT
Summary by CodeRabbit
Release Notes