mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: manage workspace state fixture
This commit is contained in:
@@ -6,6 +6,10 @@ import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { makeTempWorkspace, writeWorkspaceFile } from "../test-helpers/workspace.js";
|
||||
import {
|
||||
createOpenClawTestState,
|
||||
type OpenClawTestState,
|
||||
} from "../test-utils/openclaw-test-state.js";
|
||||
import {
|
||||
DEFAULT_AGENTS_FILENAME,
|
||||
DEFAULT_BOOTSTRAP_FILENAME,
|
||||
@@ -27,19 +31,18 @@ import {
|
||||
type WorkspaceBootstrapFile,
|
||||
} from "./workspace.js";
|
||||
|
||||
let testStateDir: string | undefined;
|
||||
let testState: OpenClawTestState | undefined;
|
||||
|
||||
beforeEach(async () => {
|
||||
testStateDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-workspace-state-"));
|
||||
vi.stubEnv("OPENCLAW_STATE_DIR", testStateDir);
|
||||
testState = await createOpenClawTestState({
|
||||
layout: "state-only",
|
||||
prefix: "openclaw-workspace-state-",
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
vi.unstubAllEnvs();
|
||||
if (testStateDir) {
|
||||
await fs.rm(testStateDir, { recursive: true, force: true });
|
||||
testStateDir = undefined;
|
||||
}
|
||||
await testState?.cleanup();
|
||||
testState = undefined;
|
||||
});
|
||||
|
||||
describe("resolveDefaultAgentWorkspaceDir", () => {
|
||||
|
||||
Reference in New Issue
Block a user