mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 05:27:39 +00:00
perf(test): speed up suites and reduce fs churn
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
clearSessionStoreCacheForTest,
|
||||
loadSessionStore,
|
||||
@@ -10,12 +10,23 @@ import {
|
||||
} from "./sessions.js";
|
||||
|
||||
describe("Session Store Cache", () => {
|
||||
let fixtureRoot = "";
|
||||
let caseId = 0;
|
||||
let testDir: string;
|
||||
let storePath: string;
|
||||
|
||||
beforeAll(() => {
|
||||
fixtureRoot = fs.mkdtempSync(path.join(os.tmpdir(), "session-cache-test-"));
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
if (fixtureRoot) {
|
||||
fs.rmSync(fixtureRoot, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// Create a temporary directory for test
|
||||
testDir = path.join(os.tmpdir(), `session-cache-test-${Date.now()}`);
|
||||
testDir = path.join(fixtureRoot, `case-${caseId++}`);
|
||||
fs.mkdirSync(testDir, { recursive: true });
|
||||
storePath = path.join(testDir, "sessions.json");
|
||||
|
||||
@@ -27,10 +38,6 @@ describe("Session Store Cache", () => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
// Clean up test directory
|
||||
if (fs.existsSync(testDir)) {
|
||||
fs.rmSync(testDir, { recursive: true, force: true });
|
||||
}
|
||||
clearSessionStoreCacheForTest();
|
||||
delete process.env.OPENCLAW_SESSION_CACHE_TTL_MS;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user