Skip to content

Commit 4dd0034

Browse files
committed
test: contain web media home env
1 parent 0973eb6 commit 4dd0034

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

src/media/web-media.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { resolveStateDir } from "../config/paths.js";
1010
import { resolvePreferredOpenClawTmpDir } from "../infra/tmp-openclaw-dir.js";
1111
import { createEmptyPluginRegistry } from "../plugins/registry-empty.js";
1212
import { resetPluginRuntimeStateForTest, setActivePluginRegistry } from "../plugins/runtime.js";
13+
import { withEnvAsync } from "../test-utils/env.js";
1314
import { resizeToJpeg } from "./media-services.js";
1415
import { encodePngRgba, fillPixel } from "./png-encode.js";
1516

@@ -585,17 +586,14 @@ describe("loadWebMedia", () => {
585586
});
586587

587588
it("resolves home-relative local media paths through allowed local roots", async () => {
588-
vi.stubEnv("OPENCLAW_HOME", fixtureRoot);
589-
try {
589+
await withEnvAsync({ OPENCLAW_HOME: fixtureRoot }, async () => {
590590
const result = await loadWebMedia("~/workspace/chart.png", {
591591
maxBytes: 1024 * 1024,
592592
localRoots: [workspaceDir],
593593
});
594594
expect(result.kind).toBe("image");
595595
expect(result.buffer.length).toBeGreaterThan(0);
596-
} finally {
597-
vi.unstubAllEnvs();
598-
}
596+
});
599597
});
600598

601599
it("allows validated host-read TXT files", async () => {

0 commit comments

Comments
 (0)