mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: narrow media tool state env
This commit is contained in:
@@ -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")));
|
||||
|
||||
Reference in New Issue
Block a user