Skip to content

Commit 3e59559

Browse files
committed
test: use instance helper in read truncation tests
1 parent ed00ae2 commit 3e59559

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

packages/opencode/test/tool/read.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { ReadTool } from "../../src/tool/read"
1313
import { Truncate } from "@/tool/truncate"
1414
import { Tool } from "@/tool/tool"
1515
import { Filesystem } from "@/util/filesystem"
16-
import { disposeAllInstances, provideInstance, tmpdirScoped } from "../fixture/fixture"
16+
import { disposeAllInstances, provideInstance, TestInstance, tmpdirScoped } from "../fixture/fixture"
1717
import { testEffect } from "../lib/effect"
1818

1919
const FIXTURES_DIR = path.join(import.meta.dir, "fixtures")
@@ -255,28 +255,28 @@ describe("tool.read env file permissions", () => {
255255
})
256256

257257
describe("tool.read truncation", () => {
258-
it.live("truncates large file by bytes and sets truncated metadata", () =>
258+
it.instance("truncates large file by bytes and sets truncated metadata", () =>
259259
Effect.gen(function* () {
260-
const dir = yield* tmpdirScoped()
260+
const test = yield* TestInstance
261261
const base = yield* load(path.join(FIXTURES_DIR, "models-api.json"))
262262
const target = 60 * 1024
263263
const content = base.length >= target ? base : base.repeat(Math.ceil(target / base.length))
264-
yield* put(path.join(dir, "large.json"), content)
264+
yield* put(path.join(test.directory, "large.json"), content)
265265

266-
const result = yield* exec(dir, { filePath: path.join(dir, "large.json") })
266+
const result = yield* run({ filePath: path.join(test.directory, "large.json") })
267267
expect(result.metadata.truncated).toBe(true)
268268
expect(result.output).toContain("Output capped at")
269269
expect(result.output).toContain("Use offset=")
270270
}),
271271
)
272272

273-
it.live("truncates by line count when limit is specified", () =>
273+
it.instance("truncates by line count when limit is specified", () =>
274274
Effect.gen(function* () {
275-
const dir = yield* tmpdirScoped()
275+
const test = yield* TestInstance
276276
const lines = Array.from({ length: 100 }, (_, i) => `line${i}`).join("\n")
277-
yield* put(path.join(dir, "many-lines.txt"), lines)
277+
yield* put(path.join(test.directory, "many-lines.txt"), lines)
278278

279-
const result = yield* exec(dir, { filePath: path.join(dir, "many-lines.txt"), limit: 10 })
279+
const result = yield* run({ filePath: path.join(test.directory, "many-lines.txt"), limit: 10 })
280280
expect(result.metadata.truncated).toBe(true)
281281
expect(result.output).toContain("Showing lines 1-10 of 100")
282282
expect(result.output).toContain("Use offset=11")
@@ -286,12 +286,12 @@ describe("tool.read truncation", () => {
286286
}),
287287
)
288288

289-
it.live("does not truncate small file", () =>
289+
it.instance("does not truncate small file", () =>
290290
Effect.gen(function* () {
291-
const dir = yield* tmpdirScoped()
292-
yield* put(path.join(dir, "small.txt"), "hello world")
291+
const test = yield* TestInstance
292+
yield* put(path.join(test.directory, "small.txt"), "hello world")
293293

294-
const result = yield* exec(dir, { filePath: path.join(dir, "small.txt") })
294+
const result = yield* run({ filePath: path.join(test.directory, "small.txt") })
295295
expect(result.metadata.truncated).toBe(false)
296296
expect(result.output).toContain("End of file")
297297
}),

0 commit comments

Comments
 (0)