mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-22 07:20:59 +00:00
Merged via /review-pr -> /prepare-pr -> /merge-pr.
Prepared head SHA: 26523f8a38
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
19 lines
627 B
TypeScript
19 lines
627 B
TypeScript
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}).`);
|
|
},
|
|
};
|
|
}
|