mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 22:44:36 +00:00
fix(ci): stabilize media and session store tests
This commit is contained in:
@@ -5,6 +5,7 @@ import os from "node:os";
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
import type { DiscordExecApprovalConfig } from "../../config/types.discord.js";
|
import type { DiscordExecApprovalConfig } from "../../config/types.discord.js";
|
||||||
|
import { clearSessionStoreCacheForTest } from "../../config/sessions.js";
|
||||||
import {
|
import {
|
||||||
buildExecApprovalCustomId,
|
buildExecApprovalCustomId,
|
||||||
extractDiscordChannelId,
|
extractDiscordChannelId,
|
||||||
@@ -19,6 +20,8 @@ const STORE_PATH = path.join(os.tmpdir(), "openclaw-exec-approvals-test.json");
|
|||||||
|
|
||||||
const writeStore = (store: Record<string, unknown>) => {
|
const writeStore = (store: Record<string, unknown>) => {
|
||||||
fs.writeFileSync(STORE_PATH, `${JSON.stringify(store, null, 2)}\n`, "utf8");
|
fs.writeFileSync(STORE_PATH, `${JSON.stringify(store, null, 2)}\n`, "utf8");
|
||||||
|
// CI runners can have coarse mtime resolution; avoid returning stale cached stores.
|
||||||
|
clearSessionStoreCacheForTest();
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|||||||
@@ -101,7 +101,12 @@ describe("web media loading", () => {
|
|||||||
// Ensure state dir is stable and not influenced by other tests that stub OPENCLAW_STATE_DIR.
|
// Ensure state dir is stable and not influenced by other tests that stub OPENCLAW_STATE_DIR.
|
||||||
// Also keep it outside os.tmpdir() so tmpdir localRoots doesn't accidentally make all state readable.
|
// Also keep it outside os.tmpdir() so tmpdir localRoots doesn't accidentally make all state readable.
|
||||||
previousStateDir = process.env.OPENCLAW_STATE_DIR;
|
previousStateDir = process.env.OPENCLAW_STATE_DIR;
|
||||||
process.env.OPENCLAW_STATE_DIR = path.join(os.homedir(), ".openclaw-media-state-test");
|
process.env.OPENCLAW_STATE_DIR = path.join(
|
||||||
|
path.parse(os.tmpdir()).root,
|
||||||
|
"var",
|
||||||
|
"lib",
|
||||||
|
"openclaw-media-state-test",
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
|||||||
Reference in New Issue
Block a user