mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-12 19:00:43 +00:00
test: dedupe test state absence assertions
This commit is contained in:
@@ -3,6 +3,10 @@ import path from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createOpenClawTestState, withOpenClawTestState } from "./openclaw-test-state.js";
|
||||
|
||||
async function expectPathMissing(targetPath: string): Promise<void> {
|
||||
await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
|
||||
}
|
||||
|
||||
describe("openclaw test state", () => {
|
||||
it("creates an isolated home layout with spawn env and restores process env", async () => {
|
||||
const previousHome = process.env.HOME;
|
||||
@@ -35,7 +39,7 @@ describe("openclaw test state", () => {
|
||||
expect(process.env.OPENCLAW_HOME).toBe(previousOpenClawHome);
|
||||
expect(process.env.OPENCLAW_STATE_DIR).toBe(previousStateDir);
|
||||
expect(process.env.OPENCLAW_CONFIG_PATH).toBe(previousConfigPath);
|
||||
await expect(fs.stat(state.root)).rejects.toThrow();
|
||||
await expectPathMissing(state.root);
|
||||
});
|
||||
|
||||
it("supports state-only layout without overriding HOME", async () => {
|
||||
@@ -51,7 +55,7 @@ describe("openclaw test state", () => {
|
||||
expect(process.env.OPENCLAW_STATE_DIR).toBe(state.stateDir);
|
||||
expect(process.env.OPENCLAW_CONFIG_PATH).toBe(state.configPath);
|
||||
expect(state.env.HOME).toBe(previousHome);
|
||||
await expect(fs.stat(state.configPath)).rejects.toThrow();
|
||||
await expectPathMissing(state.configPath);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user