mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 20:40:42 +00:00
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import { vi } from "vitest";
|
|
import { createNonExitingRuntime, type RuntimeEnv } from "../runtime.js";
|
|
|
|
export const resolveCleanupPlanFromDisk = vi.fn();
|
|
export const removePath = vi.fn();
|
|
export const listAgentSessionDirs = vi.fn();
|
|
export const removeStateAndLinkedPaths = vi.fn();
|
|
export const removeWorkspaceDirs = vi.fn();
|
|
|
|
vi.mock("../config/config.js", () => ({
|
|
isNixMode: false,
|
|
}));
|
|
|
|
vi.mock("./cleanup-plan.js", () => ({
|
|
resolveCleanupPlanFromDisk,
|
|
}));
|
|
|
|
vi.mock("./cleanup-utils.js", () => ({
|
|
removePath,
|
|
listAgentSessionDirs,
|
|
removeStateAndLinkedPaths,
|
|
removeWorkspaceDirs,
|
|
}));
|
|
|
|
export function createCleanupCommandRuntime() {
|
|
return createNonExitingRuntime();
|
|
}
|
|
|
|
export function resetCleanupCommandMocks() {
|
|
vi.clearAllMocks();
|
|
resolveCleanupPlanFromDisk.mockReturnValue({
|
|
stateDir: "/tmp/.openclaw",
|
|
configPath: "/tmp/.openclaw/openclaw.json",
|
|
oauthDir: "/tmp/.openclaw/credentials",
|
|
configInsideState: true,
|
|
oauthInsideState: true,
|
|
workspaceDirs: ["/tmp/.openclaw/workspace"],
|
|
});
|
|
removePath.mockResolvedValue({ ok: true });
|
|
listAgentSessionDirs.mockResolvedValue(["/tmp/.openclaw/agents/main/sessions"]);
|
|
removeStateAndLinkedPaths.mockResolvedValue(undefined);
|
|
removeWorkspaceDirs.mockResolvedValue(undefined);
|
|
}
|
|
|
|
export function silenceCleanupCommandRuntime(runtime: RuntimeEnv) {
|
|
vi.spyOn(runtime, "log").mockImplementation(() => {});
|
|
vi.spyOn(runtime, "error").mockImplementation(() => {});
|
|
}
|