test(memory): dedupe model-auth mock setup

This commit is contained in:
Peter Steinberger
2026-02-18 13:17:44 +00:00
parent 28b8101eef
commit ff50d3303d
3 changed files with 21 additions and 18 deletions

View File

@@ -3,15 +3,10 @@ import * as authModule from "../agents/model-auth.js";
import { type FetchMock, withFetchPreconnect } from "../test-utils/fetch-mock.js";
import { createVoyageEmbeddingProvider, normalizeVoyageModel } from "./embeddings-voyage.js";
vi.mock("../agents/model-auth.js", () => ({
resolveApiKeyForProvider: vi.fn(),
requireApiKey: (auth: { apiKey?: string; mode?: string }, provider: string) => {
if (auth?.apiKey) {
return auth.apiKey;
}
throw new Error(`No API key resolved for provider "${provider}" (auth mode: ${auth?.mode}).`);
},
}));
vi.mock("../agents/model-auth.js", async () => {
const { createModelAuthMockModule } = await import("../test-utils/model-auth-mock.js");
return createModelAuthMockModule();
});
const createFetchMock = () => {
const fetchMock = vi.fn<FetchMock>(