Skip to content

Commit 2b8c089

Browse files
committed
fix: guard current turn state env
1 parent 1d1c2f4 commit 2b8c089

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/auto-reply/reply/current-turn-images.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ import path from "node:path";
44
import { afterEach, describe, expect, it, vi } from "vitest";
55
import type { OpenClawConfig } from "../../config/types.openclaw.js";
66
import { withTempDir } from "../../test-helpers/temp-dir.js";
7+
import { deleteTestEnvValue, setTestEnvValue } from "../../test-utils/env.js";
78
import type { MsgContext } from "../templating.js";
89
import { resolveCurrentTurnImages } from "./current-turn-images.js";
910

1011
const originalStateDirEnv = process.env.OPENCLAW_STATE_DIR;
1112

1213
function restoreProcessState() {
1314
if (originalStateDirEnv === undefined) {
14-
delete process.env.OPENCLAW_STATE_DIR;
15+
deleteTestEnvValue("OPENCLAW_STATE_DIR");
1516
} else {
16-
process.env.OPENCLAW_STATE_DIR = originalStateDirEnv;
17+
setTestEnvValue("OPENCLAW_STATE_DIR", originalStateDirEnv);
1718
}
1819
}
1920

@@ -33,7 +34,7 @@ describe("resolveCurrentTurnImages", () => {
3334
await fs.mkdir(path.dirname(attachmentPath), { recursive: true });
3435
await fs.mkdir(cwd, { recursive: true });
3536
await fs.writeFile(attachmentPath, imageBytes);
36-
process.env.OPENCLAW_STATE_DIR = stateDir;
37+
setTestEnvValue("OPENCLAW_STATE_DIR", stateDir);
3738
vi.spyOn(process, "cwd").mockReturnValue(cwd);
3839

3940
const result = await resolveCurrentTurnImages({

0 commit comments

Comments
 (0)