/** * Test helper: Temporary KuzuDB factory * * Creates a temp directory, initializes KuzuDB with schema, and * optionally loads minimal test data. Returns a cleanup function. */ import fs from 'fs/promises'; import os from 'os'; import path from 'path'; export interface TestDBHandle { dbPath: string; cleanup: () => Promise; } /** * Create a temporary directory for KuzuDB tests. * Returns the path and a cleanup function. */ export async function createTempDir(prefix: string = 'gitnexus-test-'): Promise { const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), prefix)); return { dbPath: tmpDir, cleanup: async () => { try { await fs.rm(tmpDir, { recursive: true, force: true }); } catch { // best-effort cleanup } }, }; }