import { afterEach, describe, expect, test } from "bun:test"; import { mkdtemp, rm } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { openDatabase } from "./schema"; const tempRoots: string[] = []; afterEach(async () => { await Promise.all(tempRoots.splice(0).map((root) => rm(root, { recursive: true, force: true }))); }); describe("store schema", () => { test("configures a busy timeout for concurrent access", async () => { const root = await mkdtemp(join(tmpdir(), "tool-query-schema-")); tempRoots.push(root); const database = openDatabase(join(root, "index.sqlite3"), true); try { const row = database.query("PRAGMA busy_timeout").get() as { timeout: number } | null; expect(row?.timeout).toBe(30000); } finally { database.close(); } }); });