Skip to content

Commit 4000a33

Browse files
anandgupta42claude
andcommitted
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) <[email protected]>
1 parent e1f0321 commit 4000a33

4 files changed

Lines changed: 8 additions & 20 deletions

File tree

‎packages/opencode/test/altimate/registry-env-loading.test.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
import { describe, test, expect, beforeEach, afterEach } from "bun:test"
1111
import * as Registry from "../../src/altimate/native/connections/registry"
12-
import { mkdtempSync, writeFileSync, mkdirSync, rmSync } from "fs"
13-
import { tmpdir } from "os"
14-
import { join } from "path"
1512

1613
// ---------------------------------------------------------------------------
1714
// Env var cleanup helper

‎packages/opencode/test/bus/bus-event.test.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ describe("BusEvent.define", () => {
1717
})
1818

1919
describe("BusEvent.payloads", () => {
20-
// Register a known test event before payloads() tests
21-
const testSchema = z.object({ value: z.string() })
22-
BusEvent.define("__test_payloads_registered", testSchema)
23-
2420
test("includes a registered event in the discriminated union", () => {
21+
const testSchema = z.object({ value: z.string() })
22+
BusEvent.define("__test_payloads_registered", testSchema)
2523
const union = BusEvent.payloads()
2624
const result = union.safeParse({
2725
type: "__test_payloads_registered",
@@ -40,6 +38,7 @@ describe("BusEvent.payloads", () => {
4038
})
4139

4240
test("rejects event with wrong properties shape", () => {
41+
BusEvent.define("__test_payloads_registered", z.object({ value: z.string() }))
4342
const union = BusEvent.payloads()
4443
const result = union.safeParse({
4544
type: "__test_payloads_registered",

‎packages/opencode/test/command/builtin-commands.test.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ describe("Command.hints()", () => {
108108
expect(Command.hints("plain text")).toEqual([])
109109
})
110110

111-
test("sorts numbered placeholders lexicographically", () => {
112-
// Note: uses .sort() with no comparator, so $10 sorts before $2.
113-
// For single-digit placeholders, lexicographic order matches numeric.
111+
test("sorts numbered placeholders numerically", () => {
114112
expect(Command.hints("$3 then $1 then $2")).toEqual(["$1", "$2", "$3"])
115113
})
116114
})

‎packages/opencode/test/util/git.test.ts‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,30 @@ import { git } from "../../src/util/git"
44

55
describe("git() utility", () => {
66
test("runs a simple git command and returns stdout", async () => {
7-
// Use tmpdir without git:true to avoid commit signing issues; just git init manually
8-
await using tmp = await tmpdir()
9-
await Bun.spawn(["git", "init"], { cwd: tmp.path, stdout: "ignore", stderr: "ignore" }).exited
10-
await Bun.spawn(["git", "config", "core.fsmonitor", "false"], { cwd: tmp.path, stdout: "ignore", stderr: "ignore" }).exited
7+
await using tmp = await tmpdir({ git: true })
118

129
const result = await git(["rev-parse", "--is-inside-work-tree"], { cwd: tmp.path })
1310
expect(result.exitCode).toBe(0)
1411
expect(result.text().trim()).toBe("true")
1512
})
1613

1714
test("returns non-zero exit code for unknown git subcommand", async () => {
18-
await using tmp = await tmpdir()
19-
await Bun.spawn(["git", "init"], { cwd: tmp.path, stdout: "ignore", stderr: "ignore" }).exited
15+
await using tmp = await tmpdir({ git: true })
2016

2117
const result = await git(["not-a-real-subcommand"], { cwd: tmp.path })
2218
expect(result.exitCode).not.toBe(0)
2319
})
2420

2521
test("stderr is populated on error", async () => {
26-
await using tmp = await tmpdir()
27-
await Bun.spawn(["git", "init"], { cwd: tmp.path, stdout: "ignore", stderr: "ignore" }).exited
22+
await using tmp = await tmpdir({ git: true })
2823

2924
const result = await git(["checkout", "nonexistent-branch-xyz"], { cwd: tmp.path })
3025
expect(result.exitCode).not.toBe(0)
3126
expect(result.stderr.length).toBeGreaterThan(0)
3227
})
3328

3429
test("passes custom env vars through to git process", async () => {
35-
await using tmp = await tmpdir()
36-
await Bun.spawn(["git", "init"], { cwd: tmp.path, stdout: "ignore", stderr: "ignore" }).exited
30+
await using tmp = await tmpdir({ git: true })
3731

3832
// Use GIT_CONFIG_COUNT to inject a config value that only exists via env
3933
const result = await git(["config", "--get", "test.injected"], {

0 commit comments

Comments
 (0)