mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: scope openrouter capability env
This commit is contained in:
@@ -5,27 +5,33 @@ import { join } from "node:path";
|
||||
import { resetPluginStateStoreForTests } from "openclaw/plugin-sdk/plugin-state-test-runtime";
|
||||
import { importFreshModule } from "openclaw/plugin-sdk/test-fixtures";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { withEnvAsync } from "../../test-utils/env.js";
|
||||
|
||||
async function withOpenRouterStateDir(run: (stateDir: string) => Promise<void>) {
|
||||
// Each case gets an isolated state dir because the module persists capability
|
||||
// rows through the plugin state store across imports.
|
||||
const stateDir = mkdtempSync(join(tmpdir(), "openclaw-openrouter-capabilities-"));
|
||||
resetPluginStateStoreForTests();
|
||||
process.env.OPENCLAW_STATE_DIR = stateDir;
|
||||
for (const key of [
|
||||
"ALL_PROXY",
|
||||
"all_proxy",
|
||||
"HTTP_PROXY",
|
||||
"http_proxy",
|
||||
"HTTPS_PROXY",
|
||||
"https_proxy",
|
||||
]) {
|
||||
vi.stubEnv(key, "");
|
||||
}
|
||||
try {
|
||||
await run(stateDir);
|
||||
await withEnvAsync(
|
||||
{
|
||||
OPENCLAW_STATE_DIR: stateDir,
|
||||
ALL_PROXY: "",
|
||||
all_proxy: "",
|
||||
HTTP_PROXY: "",
|
||||
http_proxy: "",
|
||||
HTTPS_PROXY: "",
|
||||
https_proxy: "",
|
||||
},
|
||||
async () => {
|
||||
try {
|
||||
await run(stateDir);
|
||||
} finally {
|
||||
resetPluginStateStoreForTests();
|
||||
}
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
resetPluginStateStoreForTests();
|
||||
rmSync(stateDir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
@@ -42,7 +48,6 @@ describe("openrouter-model-capabilities", () => {
|
||||
afterEach(() => {
|
||||
resetPluginStateStoreForTests();
|
||||
vi.unstubAllGlobals();
|
||||
delete process.env.OPENCLAW_STATE_DIR;
|
||||
});
|
||||
|
||||
it("uses top-level OpenRouter max token fields when top_provider is absent", async () => {
|
||||
|
||||
Reference in New Issue
Block a user