pi-mono/packages/agent/test/harness/session-test-utils.ts
Christian Klotz 79cc1ef00a
fix(agent): own SQLite backend tests in storage package (#7626)
* fix(agent): own SQLite backend tests in storage package

* fix(agent): use lexical disposal for SQLite tests
2026-08-04 22:54:15 +03:00

20 lines
570 B
TypeScript

import { existsSync, mkdirSync, rmSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { afterEach } from "vitest";
const tempDirs: string[] = [];
export function createTempDir(): string {
const dir = join(tmpdir(), `pi-agent-session-${Date.now()}-${Math.random().toString(36).slice(2)}`);
mkdirSync(dir, { recursive: true });
tempDirs.push(dir);
return dir;
}
afterEach(() => {
while (tempDirs.length > 0) {
const dir = tempDirs.pop()!;
if (existsSync(dir)) rmSync(dir, { recursive: true, force: true });
}
});