Skip to content

test: consolidate 11 test PRs — 305 new tests, deduplicated#498

Open
anandgupta42 wants to merge 2 commits intomainfrom
test/consolidate-test-coverage
Open

test: consolidate 11 test PRs — 305 new tests, deduplicated#498
anandgupta42 wants to merge 2 commits intomainfrom
test/consolidate-test-coverage

Conversation

@anandgupta42
Copy link
Contributor

@anandgupta42 anandgupta42 commented Mar 27, 2026

What does this PR do?

Consolidates 11 scattered test PRs into a single, deduplicated test suite adding 305 new tests across 13 files.

PRs consolidated: #440, #441, #479, #483, #484, #485, #490, #491, #492, #495, #496

Deduplication performed:

New test files (11):

File Tests Coverage
sql-analyze-tool.test.ts 6 SqlAnalyzeTool formatting
sql-analyze-format.test.ts 5 sql.analyze success semantics
builtin-commands.test.ts 10 Altimate builtin command registration
hints-discover-mcps.test.ts 11 Command.hints() + discover-and-add-mcps
fingerprint-detect.test.ts 11 File-based project detection rules
dbt-lineage-helpers.test.ts 13 dbt lineage helper functions
registry-env-loading.test.ts 8 ALTIMATE_CODE_CONN_* env var loading
warehouse-telemetry.test.ts 4 MongoDB auth detection telemetry
bus-event.test.ts 5 Bus event registry payloads
git.test.ts 5 Git utility functions
keybind.test.ts 22 Keybind parsing, matching, fromParsedKey

Merged into existing files (3):

  • connections.test.ts — +24 tests (loadFromEnv, detectAuthMethod, credential stripping, containerToConfig, dbt profiles edge cases)
  • driver-normalize.test.ts — +13 MongoDB alias resolution tests
  • fixture.ts — disable commit.gpgsign in test tmpdir

Bug fixes in tests:

  • Fixed flaky registry-env-loading assertion that assumed isolated env
  • Fixed hints-discover-mcps sort order expectation to match actual behavior

Not included: PR #424 (bug fixes to source files) — kept separate as it requires updating existing error propagation tests. PR #494 (Docker/CI sanity suite) — kept separate as it's infrastructure changes.

Type of change

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

Issue for this PR

Closes #497

How did you verify your code works?

bun test  # 5108 pass, 0 fail, 436 skip across 254 files (100s)
bun run script/upstream/analyze.ts --markers --base main --strict  # OK

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

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded test coverage across connections, DBT lineage, SQL analysis/formatting, command discovery, project fingerprinting, and utilities.
    • Added env-var connection loading, MongoDB normalization, auth-method detection, credential sanitization, and Docker config edge-case tests.
    • Improved error-paths, caching/deduplication, parsing edge cases, and reporting/formatting validations for more robust behavior.

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>
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.

@gitguardian
Copy link

gitguardian bot commented Mar 27, 2026

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
29254673 Triggered Generic Password e1f0321 packages/opencode/test/altimate/connections.test.ts View secret
29254674 Triggered Generic Password e1f0321 packages/opencode/test/altimate/connections.test.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@coderabbitai
Copy link

coderabbitai bot commented Mar 27, 2026

📝 Walkthrough

Walkthrough

This PR adds many new and expanded unit tests across the repo (connections/registry, dbt lineage, SQL analysis, commands, utilities, event bus, fingerprinting) and a minor fixture change disabling git commit signing for temp repos. Tests exercise parsing, normalization, detection, formatting, and error paths.

Changes

Cohort / File(s) Summary
Connection Registry & Auth
packages/opencode/test/altimate/connections.test.ts, packages/opencode/test/altimate/registry-env-loading.test.ts, packages/opencode/test/altimate/driver-normalize.test.ts, packages/opencode/test/altimate/warehouse-telemetry.test.ts
Added tests for env-var-based Registry.load(), ALTIMATE_CODE_CONN_* parsing and name lowercasing, MongoDB alias normalization and precedence, detectAuthMethod behavior across config shapes, and credential-store stripping warnings.
dbt Lineage Helpers
packages/opencode/test/altimate/dbt-lineage-helpers.test.ts
New comprehensive tests for dbtLineage: model resolution (unique_id and short name), confidence scoring, dialect handling, schema-context/compiled SQL behavior, and manifest error cases (missing, invalid, missing nodes/compiled SQL).
SQL Analysis
packages/opencode/test/altimate/sql-analyze-format.test.ts, packages/opencode/test/altimate/sql-analyze-tool.test.ts
Tests for sql.analyze dispatcher and formatter: issue count/fields, allowed issue types, confidence fields, title construction (pluralization and parse-error substitution), and formatAnalysis output shapes.
Commands & Hints
packages/opencode/test/command/builtin-commands.test.ts, packages/opencode/test/command/hints-discover-mcps.test.ts
Tests for builtin command registration and metadata, Command.hints() placeholder extraction including numeric sorting, deduplication, $ARGUMENTS handling, and discover-and-add-mcps template presence.
Fingerprint Detection
packages/opencode/test/altimate/fingerprint-detect.test.ts
Tests for Fingerprint.detect across markers (dbt, Airflow, Databricks, SQL), caching behavior, tag deduplication, and combined cwd/root scanning.
Utility Functions
packages/opencode/test/util/keybind.test.ts, packages/opencode/test/util/git.test.ts
Keybind parsing/matching/formatting tests (modifiers, aliases, leader, special keys) and git(...) utility tests (exit codes, stdout/stderr, env passthrough, invalid cwd).
Event Bus
packages/opencode/test/bus/bus-event.test.ts
Tests for BusEvent.define and BusEvent.payloads() validating type/schema registration, discriminated union parsing, and overwrite semantics on duplicate defines.
Test Fixture
packages/opencode/test/fixture/fixture.ts
Minor change: disable commit.gpgsign in temporary git repos to avoid signed-commit failures in test fixtures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • suryaiyer95
  • mdesmet

Poem

🐰 I hopped through tests both near and far,

dbt, Mongo, SQL — each got a star.
Registry, hints, and keybinds too,
Fixtures tidy, git signed off, woohoo!
Small rabbit clap — more coverage, whoo-hoo!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'test: consolidate 11 test PRs — 305 new tests, deduplicated' is specific, clear, and directly summarizes the main change: consolidating multiple test PRs into one suite with deduplication.
Description check ✅ Passed The description comprehensively explains the consolidation effort, deduplication strategy, new test files with counts, merged files, bug fixes, and verification steps, exceeding template requirements.

✏️ 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/consolidate-test-coverage

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (5)
packages/opencode/test/util/keybind.test.ts (1)

214-232: Consider using the actual ParsedKey type instead of as any.

The tests use as any to cast the parsed key objects. If Keybind exports or exposes the ParsedKey type from its dependency, using it would provide better type safety and make the test data more self-documenting.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/test/util/keybind.test.ts` around lines 214 - 232, The
tests currently cast parsed key objects with "as any", losing type safety;
update the tests to import and use the actual ParsedKey type (or the exported
type alias) and cast the test objects to ParsedKey when calling
Keybind.fromParsedKey; locate the test file references to Keybind.fromParsedKey
and replace "as any" with the imported ParsedKey type (e.g., import { ParsedKey
} from the module that exports Keybind) so the literal objects conform to the
ParsedKey shape and the compiler validates the test fixtures.
packages/opencode/test/altimate/fingerprint-detect.test.ts (1)

12-63: Optional: consider table-driven cases to reduce repetition.

The marker-detection tests follow the same setup/write/detect/assert pattern; parameterizing them would make future additions cheaper and keep this file shorter.

♻️ Example refactor shape
+const cases = [
+  { name: "dbt_project.yml", files: [["dbt_project.yml", "name: my_project\n"]], tags: ["dbt", "data-engineering"] },
+  { name: "profiles.yml snowflake", files: [["profiles.yml", "my_profile:\n  outputs:\n    dev:\n      type: snowflake\n"]], tags: ["snowflake"] },
+  // ...
+]
+
+for (const c of cases) {
+  test(`detects tags for ${c.name}`, async () => {
+    await using tmp = await tmpdir()
+    for (const [file, content] of c.files) {
+      await fs.writeFile(path.join(tmp.path, file), content)
+    }
+    const result = await Fingerprint.detect(tmp.path)
+    for (const tag of c.tags) expect(result.tags).toContain(tag)
+  })
+}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/test/altimate/fingerprint-detect.test.ts` around lines 12 -
63, Multiple tests repeat the same setup/write/detect/assert pattern around
Fingerprint.detect; replace them with a table-driven approach (e.g., test.each
or a loop over an array of cases) where each case includes the marker (filename
or directory name like "dbt_project.yml", "profiles.yml", ".sqlfluff",
"query.sql", "airflow.cfg", "dags", "databricks.yml"), the file contents or an
indicator to mkdir, and the expected tag(s) (e.g., "dbt", "data-engineering",
"snowflake", "sql", "airflow", "databricks"); in the test body create a tmpdir
(using the existing tmpdir()/using tmp pattern), apply the case-specific setup
(write file or mkdir), call Fingerprint.detect(tmp.path), and assert expected
tags with expect(result.tags).toContain(...). This keeps the logic in one
parametrized test and removes repeated test blocks like the individual "detects
..." tests.
packages/opencode/test/altimate/dbt-lineage-helpers.test.ts (2)

269-278: Hardcoded /tmp path may cause issues on non-Unix platforms.

The path /tmp/definitely-not-a-manifest.json is Unix-specific. While this test likely runs only on Unix-like systems, using os.tmpdir() would be more portable.

♻️ Suggested fix for cross-platform compatibility
+import { tmpdir as osTmpdir } from "os"
+
 // ...
 
   test("returns low confidence for non-existent manifest", () => {
+    const nonExistentPath = join(osTmpdir(), "definitely-not-a-manifest-" + Date.now() + ".json")
     const result = dbtLineage({
-      manifest_path: "/tmp/definitely-not-a-manifest.json",
+      manifest_path: nonExistentPath,
       model: "orders",
     })
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/test/altimate/dbt-lineage-helpers.test.ts` around lines 269
- 278, The test uses a hardcoded Unix-only path
"/tmp/definitely-not-a-manifest.json"; update the test that calls dbtLineage
(test "returns low confidence for non-existent manifest") to build the
non-existent manifest path using the platform temp directory (e.g.,
path.join(os.tmpdir(), "definitely-not-a-manifest.json")) so it works
cross-platform—import the Node 'os' (and 'path' if needed) in the test file and
replace the literal string with the constructed tmp path when calling
dbtLineage.

13-14: Consider using the project's tmpdir utility from fixture/fixture.ts.

The coding guidelines specify using the tmpdir function from fixture/fixture.ts with await using syntax for automatic cleanup. The current implementation manually manages temporary directories with mkdtempSync and afterEach cleanup.

Refactoring to use the project's utility would improve consistency across the test suite.

♻️ Suggested refactor using fixture tmpdir
 import { describe, test, expect, afterEach } from "bun:test"
 import { dbtLineage } from "../../src/altimate/native/dbt/lineage"
-import { writeFileSync, mkdtempSync, rmSync } from "fs"
-import { tmpdir } from "os"
+import { writeFileSync } from "fs"
 import { join } from "path"
+import { tmpdir } from "../fixture/fixture"

Then update each test to use await using:

 describe("dbtLineage: model lookup", () => {
-  test("finds model by unique_id", () => {
-    const dir = makeTmpDir()
+  test("finds model by unique_id", async () => {
+    await using tmp = await tmpdir()
+    const dir = tmp.path
     const manifestPath = writeManifest(dir, BASE_MANIFEST)
     // ...
   })
 })

This eliminates the need for the tmpDirs array, makeTmpDir() helper, and afterEach cleanup block entirely.

As per coding guidelines: "Use the tmpdir function from fixture/fixture.ts to create temporary directories for tests with automatic cleanup" and "Always use await using syntax with tmpdir() for automatic cleanup when the variable goes out of scope".

Also applies to: 21-40

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/test/altimate/dbt-lineage-helpers.test.ts` around lines 13
- 14, Replace manual temp-dir handling (mkdtempSync, tmpDirs array, makeTmpDir
helper, and the afterEach cleanup) by importing the project's tmpdir utility
from fixture/fixture.ts and using it with the `await using` syntax inside each
test; update tests that call makeTmpDir() to instead `await using` the
tmpdir(...) returned resource and remove the tmpDirs collection and afterEach
block entirely so cleanup is automatic. Ensure you remove the top-level import
of tmpdir from "os" and the fs/mkdtempSync usage, and update any references to
temporary directory paths to use the variable provided by the tmpdir fixture in
the test bodies.
packages/opencode/test/altimate/registry-env-loading.test.ts (1)

12-14: Remove unused imports.

The mkdtempSync, writeFileSync, mkdirSync, rmSync from fs, tmpdir from os, and join from path are imported but never used in this test file. The tests only manipulate process.env without creating temporary files.

🧹 Remove dead imports
 import { describe, test, expect, beforeEach, afterEach } from "bun:test"
 import * as Registry from "../../src/altimate/native/connections/registry"
-import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from "fs"
-import { tmpdir } from "os"
-import { join } from "path"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/test/altimate/registry-env-loading.test.ts` around lines 12
- 14, Remove the unused imports mkdtempSync, writeFileSync, mkdirSync, rmSync
(from fs), tmpdir (from os), and join (from path) from the top of the test file;
update the import statements to only include any actually used symbols (or
remove the import lines entirely if nothing is used) and run the linter/tests to
confirm no references remain (look for these symbols in
registry-env-loading.test.ts to ensure no further usage).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/opencode/test/bus/bus-event.test.ts`:
- Around line 20-23: The test currently calls
BusEvent.define("__test_payloads_registered", ...) at module scope which mutates
the global BusEvent registry during import; move this registration into each
test (e.g., inside the payloads() tests) or generate a unique event name per
test and/or call a BusEvent.reset() helper before/after each test so
registrations do not leak across tests—update the tests that reference
BusEvent.define (including the instances around lines with payloads() and the
block at 52-58) to perform define/reset within their test lifecycle to ensure
isolation.

In `@packages/opencode/test/command/builtin-commands.test.ts`:
- Around line 111-114: The test's title and inline comment incorrectly state
lexicographic ordering; update the test description and comment to reflect that
Command.hints(...) performs numeric sorting of placeholders. Locate the test
using the symbol Command.hints in builtin-commands.test.ts and change the test
name and the note to indicate numeric (numeric-aware) ordering (e.g., "sorts
numbered placeholders numerically") and remove or replace the misleading remark
about .sort() lexicographic behavior so the test intent matches the
implementation.

In `@packages/opencode/test/util/git.test.ts`:
- Around line 7-10: Tests are manually running git init via Bun.spawn; replace
those manual setups by using the test fixture tmpdir({ git: true }) so the temp
dir is created with a git root commit and consistent fixture behavior—update the
three places that call tmpdir() and then Bun.spawn(["git","init"], ...) (and the
accompanying Bun.spawn(["git","config","core.fsmonitor", "false"], ...)) to
instead call tmpdir({ git: true }) and remove the manual Bun.spawn invocations;
ensure you make the same change for the other occurrences in this file that use
tmpdir + Bun.spawn for git init.

---

Nitpick comments:
In `@packages/opencode/test/altimate/dbt-lineage-helpers.test.ts`:
- Around line 269-278: The test uses a hardcoded Unix-only path
"/tmp/definitely-not-a-manifest.json"; update the test that calls dbtLineage
(test "returns low confidence for non-existent manifest") to build the
non-existent manifest path using the platform temp directory (e.g.,
path.join(os.tmpdir(), "definitely-not-a-manifest.json")) so it works
cross-platform—import the Node 'os' (and 'path' if needed) in the test file and
replace the literal string with the constructed tmp path when calling
dbtLineage.
- Around line 13-14: Replace manual temp-dir handling (mkdtempSync, tmpDirs
array, makeTmpDir helper, and the afterEach cleanup) by importing the project's
tmpdir utility from fixture/fixture.ts and using it with the `await using`
syntax inside each test; update tests that call makeTmpDir() to instead `await
using` the tmpdir(...) returned resource and remove the tmpDirs collection and
afterEach block entirely so cleanup is automatic. Ensure you remove the
top-level import of tmpdir from "os" and the fs/mkdtempSync usage, and update
any references to temporary directory paths to use the variable provided by the
tmpdir fixture in the test bodies.

In `@packages/opencode/test/altimate/fingerprint-detect.test.ts`:
- Around line 12-63: Multiple tests repeat the same setup/write/detect/assert
pattern around Fingerprint.detect; replace them with a table-driven approach
(e.g., test.each or a loop over an array of cases) where each case includes the
marker (filename or directory name like "dbt_project.yml", "profiles.yml",
".sqlfluff", "query.sql", "airflow.cfg", "dags", "databricks.yml"), the file
contents or an indicator to mkdir, and the expected tag(s) (e.g., "dbt",
"data-engineering", "snowflake", "sql", "airflow", "databricks"); in the test
body create a tmpdir (using the existing tmpdir()/using tmp pattern), apply the
case-specific setup (write file or mkdir), call Fingerprint.detect(tmp.path),
and assert expected tags with expect(result.tags).toContain(...). This keeps the
logic in one parametrized test and removes repeated test blocks like the
individual "detects ..." tests.

In `@packages/opencode/test/altimate/registry-env-loading.test.ts`:
- Around line 12-14: Remove the unused imports mkdtempSync, writeFileSync,
mkdirSync, rmSync (from fs), tmpdir (from os), and join (from path) from the top
of the test file; update the import statements to only include any actually used
symbols (or remove the import lines entirely if nothing is used) and run the
linter/tests to confirm no references remain (look for these symbols in
registry-env-loading.test.ts to ensure no further usage).

In `@packages/opencode/test/util/keybind.test.ts`:
- Around line 214-232: The tests currently cast parsed key objects with "as
any", losing type safety; update the tests to import and use the actual
ParsedKey type (or the exported type alias) and cast the test objects to
ParsedKey when calling Keybind.fromParsedKey; locate the test file references to
Keybind.fromParsedKey and replace "as any" with the imported ParsedKey type
(e.g., import { ParsedKey } from the module that exports Keybind) so the literal
objects conform to the ParsedKey shape and the compiler validates the test
fixtures.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 40eb57ed-af9b-44d1-a62a-b24dbccdb7dd

📥 Commits

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

📒 Files selected for processing (14)
  • packages/opencode/test/altimate/connections.test.ts
  • packages/opencode/test/altimate/dbt-lineage-helpers.test.ts
  • packages/opencode/test/altimate/driver-normalize.test.ts
  • packages/opencode/test/altimate/fingerprint-detect.test.ts
  • packages/opencode/test/altimate/registry-env-loading.test.ts
  • packages/opencode/test/altimate/sql-analyze-format.test.ts
  • packages/opencode/test/altimate/sql-analyze-tool.test.ts
  • packages/opencode/test/altimate/warehouse-telemetry.test.ts
  • packages/opencode/test/bus/bus-event.test.ts
  • packages/opencode/test/command/builtin-commands.test.ts
  • packages/opencode/test/command/hints-discover-mcps.test.ts
  • packages/opencode/test/fixture/fixture.ts
  • packages/opencode/test/util/git.test.ts
  • packages/opencode/test/util/keybind.test.ts

- `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>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/opencode/test/util/git.test.ts (1)

46-50: Consider aligning assertion with test name.

The test name states "returns exitCode 1" but the assertion checks not.toBe(0). Since the git() implementation explicitly returns exitCode: 1 in its catch block (see packages/opencode/src/util/git.ts), you could make the assertion more precise:

-    expect(result.exitCode).not.toBe(0)
+    expect(result.exitCode).toBe(1)

This is a minor nitpick - the current test is functionally correct and will catch regressions.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/opencode/test/util/git.test.ts` around lines 46 - 50, The test's
assertion is more permissive than its name: update the test for the git(...)
call (the test that checks behavior when cwd does not exist) to assert the exact
exit code returned by the implementation; replace the loose
expect(result.exitCode).not.toBe(0) with expect(result.exitCode).toBe(1) (keep
the existing stdout length assertion) so the test aligns with the git function's
catch behavior which returns exitCode 1.
🤖 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/util/git.test.ts`:
- Around line 46-50: The test's assertion is more permissive than its name:
update the test for the git(...) call (the test that checks behavior when cwd
does not exist) to assert the exact exit code returned by the implementation;
replace the loose expect(result.exitCode).not.toBe(0) with
expect(result.exitCode).toBe(1) (keep the existing stdout length assertion) so
the test aligns with the git function's catch behavior which returns exitCode 1.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6c14a09a-df47-4022-89fd-c6555913df10

📥 Commits

Reviewing files that changed from the base of the PR and between e1f0321 and 4000a33.

📒 Files selected for processing (4)
  • packages/opencode/test/altimate/registry-env-loading.test.ts
  • packages/opencode/test/bus/bus-event.test.ts
  • packages/opencode/test/command/builtin-commands.test.ts
  • packages/opencode/test/util/git.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/opencode/test/altimate/registry-env-loading.test.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/opencode/test/bus/bus-event.test.ts
  • packages/opencode/test/command/builtin-commands.test.ts

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.

test: consolidate scattered test PRs into single suite

1 participant