test: contain media roots state env

This commit is contained in:
Shakker
2026-06-05 02:05:18 +01:00
parent 6f419b3853
commit e282cb2af5

View File

@@ -1,7 +1,8 @@
// Local media root tests cover allowed root normalization and matching.
import path from "node:path";
import { pathToFileURL } from "node:url";
import { afterEach, describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { withEnv } from "../test-utils/env.js";
import {
appendLocalMediaParentRoots,
buildMediaLocalRoots,
@@ -16,8 +17,7 @@ function normalizeHostPath(value: string): string {
describe("local media roots", () => {
function withStateDir<T>(stateDir: string, run: () => T): T {
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
return run();
return withEnv({ OPENCLAW_STATE_DIR: stateDir }, run);
}
function expectNormalizedRootsContain(
@@ -73,10 +73,6 @@ describe("local media roots", () => {
}
}
afterEach(() => {
vi.unstubAllEnvs();
});
it.each([
{
name: "keeps temp, media cache, canvas, and workspace roots by default",