test: isolate sandbox registry state env · openclaw/openclaw@3b65f1d
shakkernerd
·
2026-06-20
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -17,7 +17,7 @@ const {
|
17 | 17 | const { tmpdir } = require("node:os"); |
18 | 18 | const baseDir = mkdtempSync(nodePath.join(tmpdir(), "openclaw-sandbox-registry-")); |
19 | 19 | const previousStateDir = process.env.OPENCLAW_STATE_DIR; |
20 | | -process.env.OPENCLAW_STATE_DIR = baseDir; |
| 20 | +Reflect.set(process.env, "OPENCLAW_STATE_DIR", baseDir); |
21 | 21 | |
22 | 22 | return { |
23 | 23 | TEST_STATE_DIR: baseDir, |
@@ -38,6 +38,7 @@ vi.mock("./constants.js", () => ({
|
38 | 38 | })); |
39 | 39 | |
40 | 40 | import { closeOpenClawStateDatabaseForTest } from "../../state/openclaw-state-db.js"; |
| 41 | +import { deleteTestEnvValue, setTestEnvValue } from "../../test-utils/env.js"; |
41 | 42 | import { hashTextSha256 } from "./hash.js"; |
42 | 43 | import { |
43 | 44 | migrateLegacySandboxRegistryFiles, |
@@ -77,9 +78,9 @@ afterAll(async () => {
|
77 | 78 | closeOpenClawStateDatabaseForTest(); |
78 | 79 | await fs.rm(TEST_STATE_DIR, { recursive: true, force: true }); |
79 | 80 | if (PREVIOUS_OPENCLAW_STATE_DIR === undefined) { |
80 | | -delete process.env.OPENCLAW_STATE_DIR; |
| 81 | +deleteTestEnvValue("OPENCLAW_STATE_DIR"); |
81 | 82 | } else { |
82 | | -process.env.OPENCLAW_STATE_DIR = PREVIOUS_OPENCLAW_STATE_DIR; |
| 83 | +setTestEnvValue("OPENCLAW_STATE_DIR", PREVIOUS_OPENCLAW_STATE_DIR); |
83 | 84 | } |
84 | 85 | }); |
85 | 86 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。