Skip to content

Commit f9b858d

Browse files
fix: raise brain_reindex tool-definition test timeout to 20s (#204) (#205)
* fix: raise brain_reindex tool-definition test timeout to 20s #204 * fix: isolate brain_reindex tool-definition test DB via HOME temp dir #204
1 parent b6f9b72 commit f9b858d

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

‎test/reindex.test.ts‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import { Database } from "bun:sqlite";
77
import { createSchema, generateId, hashContent } from "../src/schema";
88
import { brainSearch } from "../src/search/unified";
99
import plugin from "../src/four-opencode-brain";
10+
import { mkdtempSync } from "fs";
11+
import { tmpdir } from "os";
12+
import { join } from "path";
1013

1114
let db: Database;
1215

@@ -34,17 +37,23 @@ function tableExists(name: string): boolean {
3437

3538
describe("brain_reindex — tool definition", () => {
3639
test("plugin exports brain_reindex tool", async () => {
37-
const result = await plugin.server({
38-
client: {} as any,
39-
project: "test",
40-
directory: "/tmp",
41-
$: {} as any,
42-
});
43-
expect(result.tool).toHaveProperty("brain_reindex");
44-
const tool = result.tool.brain_reindex;
45-
expect(tool).toBeDefined();
46-
expect(tool.description).toContain("Rebuild vec0 vector index");
47-
expect(tool.args).toEqual({});
40+
const originalHome = process.env.HOME;
41+
process.env.HOME = mkdtempSync(join(tmpdir(), "brain-test-"));
42+
try {
43+
const result = await plugin.server({
44+
client: {} as any,
45+
project: "test",
46+
directory: "/tmp",
47+
$: {} as any,
48+
});
49+
expect(result.tool).toHaveProperty("brain_reindex");
50+
const tool = result.tool.brain_reindex;
51+
expect(tool).toBeDefined();
52+
expect(tool.description).toContain("Rebuild vec0 vector index");
53+
expect(tool.args).toEqual({});
54+
} finally {
55+
process.env.HOME = originalHome;
56+
}
4857
});
4958
});
5059

0 commit comments

Comments
 (0)