test: narrow media tool state env

This commit is contained in:
Shakker
2026-06-05 16:54:58 +01:00
parent 8a83c13389
commit 002aa1061b

View File

@@ -2,8 +2,9 @@
// model-registry normalization for generation/understanding tools.
import path from "node:path";
import { pathToFileURL } from "node:url";
import { afterEach, describe, expect, it, vi } from "vitest";
import { describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../../config/config.js";
import { withEnv } from "../../test-utils/env.js";
import {
hasGenerationToolAvailability,
isCapabilityProviderConfigured,
@@ -59,10 +60,6 @@ function createModelRegistryStub(resolve: (provider: string, modelId: string) =>
}
describe("resolveMediaToolLocalRoots", () => {
afterEach(() => {
vi.unstubAllEnvs();
});
it("does not widen default local roots from media sources", () => {
const stateDir = path.join("/tmp", "openclaw-media-tool-roots-state");
const picturesDir =
@@ -70,13 +67,13 @@ describe("resolveMediaToolLocalRoots", () => {
const moviesDir =
process.platform === "win32" ? "C:\\Users\\peter\\Movies" : "/Users/peter/Movies";
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
const roots = resolveMediaToolLocalRoots(path.join(stateDir, "workspace-agent"), undefined, [
path.join(picturesDir, "photo.png"),
pathToFileURL(path.join(moviesDir, "clip.mp4")).href,
"/top-level-file.png",
]);
const roots = withEnv({ OPENCLAW_STATE_DIR: stateDir }, () =>
resolveMediaToolLocalRoots(path.join(stateDir, "workspace-agent"), undefined, [
path.join(picturesDir, "photo.png"),
pathToFileURL(path.join(moviesDir, "clip.mp4")).href,
"/top-level-file.png",
]),
);
const normalizedRoots = roots.map(normalizeHostPath);
expect(normalizedRoots).toContain(normalizeHostPath(path.join(stateDir, "workspace-agent")));