mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 15:40:44 +00:00
test: slim runtime hotspot mocks
This commit is contained in:
@@ -3,6 +3,24 @@ import path from "node:path";
|
||||
import type { RequestPermissionRequest } from "@agentclientprotocol/sdk";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { createTrackedTempDirs } from "../test-utils/tracked-temp-dirs.js";
|
||||
|
||||
vi.mock("../secrets/provider-env-vars.js", () => ({
|
||||
listKnownProviderAuthEnvVarNames: () => ["OPENAI_API_KEY", "GITHUB_TOKEN", "HF_TOKEN"],
|
||||
omitEnvKeysCaseInsensitive: (
|
||||
baseEnv: NodeJS.ProcessEnv,
|
||||
keys: Iterable<string>,
|
||||
): NodeJS.ProcessEnv => {
|
||||
const denied = new Set([...keys].map((key) => key.trim().toUpperCase()).filter(Boolean));
|
||||
const env = { ...baseEnv };
|
||||
for (const key of Object.keys(env)) {
|
||||
if (denied.has(key.toUpperCase())) {
|
||||
delete env[key];
|
||||
}
|
||||
}
|
||||
return env;
|
||||
},
|
||||
}));
|
||||
|
||||
import {
|
||||
buildAcpClientStripKeys,
|
||||
resolveAcpClientSpawnEnv,
|
||||
|
||||
@@ -353,13 +353,10 @@ describe("image-generation runtime", () => {
|
||||
return [];
|
||||
});
|
||||
|
||||
const promise = generateImage({ cfg: {} as OpenClawConfig, prompt: "draw a cat" });
|
||||
|
||||
await expect(promise).rejects.toThrow("No image-generation model configured.");
|
||||
await expect(promise).rejects.toThrow(
|
||||
'Set agents.defaults.imageGenerationModel.primary to a provider/model like "vision-one/paint-v1".',
|
||||
await expect(
|
||||
generateImage({ cfg: {} as OpenClawConfig, prompt: "draw a cat" }),
|
||||
).rejects.toThrow(
|
||||
'No image-generation model configured. Set agents.defaults.imageGenerationModel.primary to a provider/model like "vision-one/paint-v1". If you want a specific provider, also configure that provider\'s auth/API key first (vision-one: VISION_ONE_API_KEY; vision-two: VISION_TWO_API_KEY).',
|
||||
);
|
||||
await expect(promise).rejects.toThrow("vision-one: VISION_ONE_API_KEY");
|
||||
await expect(promise).rejects.toThrow("vision-two: VISION_TWO_API_KEY");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -757,12 +757,10 @@ describe("video-generation runtime", () => {
|
||||
]);
|
||||
mocks.getProviderEnvVars.mockReturnValue(["MOTION_ONE_API_KEY"]);
|
||||
|
||||
const promise = generateVideo({ cfg: {} as OpenClawConfig, prompt: "animate a cat" });
|
||||
|
||||
await expect(promise).rejects.toThrow("No video-generation model configured.");
|
||||
await expect(promise).rejects.toThrow(
|
||||
'Set agents.defaults.videoGenerationModel.primary to a provider/model like "motion-one/animate-v1".',
|
||||
await expect(
|
||||
generateVideo({ cfg: {} as OpenClawConfig, prompt: "animate a cat" }),
|
||||
).rejects.toThrow(
|
||||
'No video-generation model configured. Set agents.defaults.videoGenerationModel.primary to a provider/model like "motion-one/animate-v1". If you want a specific provider, also configure that provider\'s auth/API key first (motion-one: MOTION_ONE_API_KEY).',
|
||||
);
|
||||
await expect(promise).rejects.toThrow("motion-one: MOTION_ONE_API_KEY");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user