mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 04:40:43 +00:00
test: cache fallback metadata snapshot
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import crypto from "node:crypto";
|
||||
import path from "node:path";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { resetLogger, setLoggerOverride } from "../logging/logger.js";
|
||||
import { createWarnLogCapture } from "../logging/test-helpers/warn-log-capture.js";
|
||||
import {
|
||||
clearCurrentPluginMetadataSnapshot,
|
||||
setCurrentPluginMetadataSnapshot,
|
||||
} from "../plugins/current-plugin-metadata-snapshot.js";
|
||||
import { loadPluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.js";
|
||||
import { AUTH_STORE_VERSION } from "./auth-profiles/constants.js";
|
||||
import type { AuthProfileStore } from "./auth-profiles/types.js";
|
||||
import { FailoverError } from "./failover-error.js";
|
||||
@@ -27,10 +32,6 @@ vi.mock("../plugins/provider-runtime.js", () => ({
|
||||
resolveExternalAuthProfilesWithPlugins: () => [],
|
||||
}));
|
||||
|
||||
vi.mock("../plugins/manifest-model-id-normalization.js", () => ({
|
||||
normalizeProviderModelIdWithManifest: () => undefined,
|
||||
}));
|
||||
|
||||
const authSourceCheckMock = vi.hoisted(() => ({
|
||||
hasAnyAuthProfileStoreSource: vi.fn(() => false),
|
||||
}));
|
||||
@@ -145,6 +146,14 @@ const makeCfg = makeModelFallbackCfg;
|
||||
let authTempRoot = "";
|
||||
let authTempCounter = 0;
|
||||
|
||||
beforeAll(() => {
|
||||
setCurrentPluginMetadataSnapshot(loadPluginMetadataSnapshot({ config: {} }), { config: {} });
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
clearCurrentPluginMetadataSnapshot();
|
||||
});
|
||||
|
||||
function resetModelFallbackTestState(): void {
|
||||
authRuntimeMock.clear();
|
||||
authRuntimeMock.runtime.ensureAuthProfileStore.mockClear();
|
||||
@@ -955,7 +964,7 @@ describe("runWithModelFallback", () => {
|
||||
}),
|
||||
).toEqual([
|
||||
{ provider: "anthropic", model: "claude-haiku-3-5" },
|
||||
{ provider: "openrouter", model: "deepseek-chat" },
|
||||
{ provider: "openrouter", model: "openrouter/deepseek-chat" },
|
||||
{ provider: "openai", model: "gpt-4.1-mini" },
|
||||
]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user