mirror of
https://github.com/abhigyanpatwari/GitNexus.git
synced 2026-08-28 05:25:25 +00:00
- 59 test files covering unit and integration tests - vitest config with coverage thresholds and fork pooling - Test fixtures (mini-repo + multi-language sample code) - Add vitest + coverage-v8 to devDependencies - Add test scripts (test, test:integration, test:all, test:watch, test:coverage) - Move typescript to devDependencies where it belongs Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
32 lines
813 B
TypeScript
32 lines
813 B
TypeScript
/**
|
|
* 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<void>;
|
|
}
|
|
|
|
/**
|
|
* Create a temporary directory for KuzuDB tests.
|
|
* Returns the path and a cleanup function.
|
|
*/
|
|
export async function createTempDir(prefix: string = 'gitnexus-test-'): Promise<TestDBHandle> {
|
|
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
|
|
}
|
|
},
|
|
};
|
|
}
|