fix(ci): stabilize state-dir dependent tests

This commit is contained in:
Peter Steinberger
2026-02-15 17:57:13 +00:00
parent 813b96a804
commit be9b5cefbd
4 changed files with 53 additions and 24 deletions

View File

@@ -1,26 +1,31 @@
import path from "node:path";
import { describe, expect, test } from "vitest";
import type { OpenClawConfig } from "../config/config.js";
import { buildCleanupPlan } from "./cleanup-utils.js";
describe("buildCleanupPlan", () => {
test("resolves inside-state flags and workspace dirs", () => {
const tmpRoot = path.join(path.parse(process.cwd()).root, "tmp");
const cfg = {
agents: {
defaults: { workspace: "/tmp/openclaw-workspace-1" },
list: [{ workspace: "/tmp/openclaw-workspace-2" }],
defaults: { workspace: path.join(tmpRoot, "openclaw-workspace-1") },
list: [{ workspace: path.join(tmpRoot, "openclaw-workspace-2") }],
},
};
const plan = buildCleanupPlan({
cfg: cfg as unknown as OpenClawConfig,
stateDir: "/tmp/openclaw-state",
configPath: "/tmp/openclaw-state/openclaw.json",
oauthDir: "/tmp/openclaw-oauth",
stateDir: path.join(tmpRoot, "openclaw-state"),
configPath: path.join(tmpRoot, "openclaw-state", "openclaw.json"),
oauthDir: path.join(tmpRoot, "openclaw-oauth"),
});
expect(plan.configInsideState).toBe(true);
expect(plan.oauthInsideState).toBe(false);
expect(new Set(plan.workspaceDirs)).toEqual(
new Set(["/tmp/openclaw-workspace-1", "/tmp/openclaw-workspace-2"]),
new Set([
path.join(tmpRoot, "openclaw-workspace-1"),
path.join(tmpRoot, "openclaw-workspace-2"),
]),
);
});
});