File size: 627 Bytes
fc93158 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | import { vi } from "vitest";
type ModelAuthMockModule = {
resolveApiKeyForProvider: (...args: unknown[]) => unknown;
requireApiKey: (auth: { apiKey?: string; mode?: string }, provider: string) => string;
};
export function createModelAuthMockModule(): ModelAuthMockModule {
return {
resolveApiKeyForProvider: vi.fn() as (...args: unknown[]) => unknown,
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}).`);
},
};
}
|