Skip to content

test: bus events + dbt profiles parser — registry payloads and env_var defaults#483

Open
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260326-1918
Open

test: bus events + dbt profiles parser — registry payloads and env_var defaults#483
anandgupta42 wants to merge 1 commit intomainfrom
test/hourly-20260326-1918

Conversation

@anandgupta42
Copy link
Contributor

What does this PR do?

Adds 8 new tests covering two previously untested areas discovered during proactive test discovery.

1. BusEvent.define + BusEvent.payloadssrc/bus/bus-event.ts (5 new tests)

This module is the core pub/sub event registry used by 20+ modules across the codebase (sessions, files, permissions, VCS, questions, LSP, server). BusEvent.define() registers event types in a global registry, and BusEvent.payloads() builds a Zod discriminated union used in the server's SSE/HTTP API schema. Zero tests existed. New coverage includes:

  • define() contract: returns { type, properties } shape correctly
  • Registry integration: a defined event appears in payloads() discriminated union
  • Schema validation: payloads() rejects events with unregistered types
  • Schema validation: payloads() rejects events with wrong property shapes
  • Duplicate handling: last define() call wins when same type is registered twice (documents Map.set behavior)

Tests use __test_ prefixed type strings to avoid colliding with production events in the shared registry.

2. parseDbtProfilessrc/altimate/native/connections/dbt-profiles.ts (3 new tests)

The dbt profiles parser converts ~/.dbt/profiles.yml into warehouse connections. Existing tests covered basic parsing, env_var resolution, and adapter mapping, but missed three real-world edge cases:

  • env_var default fallback: dbt users commonly write {{ env_var('DB_HOST', 'localhost') }} with a default value. The regex at line 58 captures the optional second argument, but this path was never tested. If the capture group broke, users would silently get empty strings instead of their configured defaults.
  • config key skip: Real dbt profiles.yml files include a top-level config: key for global settings (e.g., send_anonymous_usage_stats: false). The parser has a guard on line 148 to skip it, but this was untested. Without it, config could be parsed as a phantom connection.
  • Multiple profiles with multiple outputs: Validates the ${profileName}_${outputName} naming convention with >1 profile, ensuring downstream code that depends on connection identity works correctly.

Type of change

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

Issue for this PR

N/A — proactive test coverage

How did you verify your code works?

bun test test/bus/bus-event.test.ts          # 5 pass
bun test test/altimate/connections.test.ts   # 42 pass (39 existing + 3 new)

Marker check passes: bun run script/upstream/analyze.ts --markers --base main --strict

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_01XZqioFNF2eYPkr9X6USeth

…r defaults

Add 8 new tests covering two previously untested areas:

- BusEvent.define/payloads: validates event registry, discriminated union
  generation, and duplicate-type overwrite behavior (5 tests)
- dbt profiles parser: env_var default fallback, config key skip, and
  multi-profile naming convention (3 tests)

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

https://claude.ai/code/session_01XZqioFNF2eYPkr9X6USeth
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.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai
Copy link

coderabbitai bot commented Mar 26, 2026

Warning

Rate limit exceeded

@anandgupta42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 1 minutes and 43 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 3efcb16c-3e0b-447d-ae1e-76d403ab6100

📥 Commits

Reviewing files that changed from the base of the PR and between 91fe351 and 8020f90.

📒 Files selected for processing (2)
  • packages/opencode/test/altimate/connections.test.ts
  • packages/opencode/test/bus/bus-event.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/hourly-20260326-1918

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.

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