mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 05:20:43 +00:00
26 lines
662 B
TypeScript
26 lines
662 B
TypeScript
import fs from "node:fs/promises";
|
|
import path from "node:path";
|
|
import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
|
|
import { afterEach, beforeEach } from "vitest";
|
|
|
|
export function installTmpDirHarness(params: { prefix: string }) {
|
|
let tmpDir = "";
|
|
let dbPath = "";
|
|
|
|
beforeEach(async () => {
|
|
tmpDir = await fs.mkdtemp(path.join(resolvePreferredOpenClawTmpDir(), params.prefix));
|
|
dbPath = path.join(tmpDir, "lancedb");
|
|
});
|
|
|
|
afterEach(async () => {
|
|
if (tmpDir) {
|
|
await fs.rm(tmpDir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
return {
|
|
getTmpDir: () => tmpDir,
|
|
getDbPath: () => dbPath,
|
|
};
|
|
}
|