mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 21:07:01 -06:00
test(sessions): close SQLite fixtures before cleanup (#113074)
This commit is contained in:
committed by
GitHub
parent
6680b0faac
commit
e9250be4bb
@@ -1,25 +1,23 @@
|
||||
// Loads fixture suites from disk for parametrized tests.
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { cleanupTempDirs, makeTempDir } from "../../test/helpers/temp-dir.js";
|
||||
|
||||
/** Creates a temp fixture root with deterministic per-case subdirectories. */
|
||||
export function createFixtureSuite(rootPrefix: string) {
|
||||
let fixtureRoot = "";
|
||||
let fixtureCount = 0;
|
||||
const fixtureRoots = new Set<string>();
|
||||
|
||||
return {
|
||||
async setup(): Promise<void> {
|
||||
// Canonicalize: macOS tmpdir sits behind a symlink (/var -> /private/var)
|
||||
// and production realpaths state/session paths, so symlinked roots break
|
||||
// path-equality assertions.
|
||||
fixtureRoot = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), rootPrefix)));
|
||||
fixtureRoot = makeTempDir(fixtureRoots, rootPrefix);
|
||||
},
|
||||
async cleanup(): Promise<void> {
|
||||
if (!fixtureRoot) {
|
||||
return;
|
||||
}
|
||||
await fs.rm(fixtureRoot, { recursive: true, force: true });
|
||||
cleanupTempDirs(fixtureRoots);
|
||||
fixtureRoot = "";
|
||||
},
|
||||
async createCaseDir(prefix: string): Promise<string> {
|
||||
|
||||
Reference in New Issue
Block a user