audit follow-up: continue warning burn-down in factory and service tests
This commit is contained in:
@@ -3,18 +3,20 @@ import { tmpdir } from 'os';
|
||||
import { join } from 'path';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { AnthropicClient } from '../models/anthropic.js';
|
||||
import { OpenAIClient } from '../models/openai.js';
|
||||
import { OllamaClient } from '../models/local/ollama.js';
|
||||
import { LlamaCppClient } from '../models/local/llamacpp.js';
|
||||
import { GeminiClient } from '../models/gemini.js';
|
||||
import { BedrockClient } from '../models/bedrock.js';
|
||||
import { GitHubModelsClient } from '../models/github.js';
|
||||
|
||||
async function loadFactory(): Promise<typeof import('./index.js')> {
|
||||
return import('./index.js');
|
||||
}
|
||||
|
||||
function getUseOAuth(client: unknown): boolean | undefined {
|
||||
const obj = client as { useOAuth?: boolean };
|
||||
return obj.useOAuth;
|
||||
}
|
||||
|
||||
function getConstructorName(value: unknown): string {
|
||||
const obj = value as { constructor?: { name?: string } };
|
||||
return obj.constructor?.name ?? '';
|
||||
}
|
||||
|
||||
describe('createClientFromConfig', () => {
|
||||
it('creates AnthropicClient for anthropic provider', async () => {
|
||||
const { createClientFromConfig } = await loadFactory();
|
||||
@@ -283,7 +285,7 @@ describe('createClientFromConfig', () => {
|
||||
api_key: 'sk-test',
|
||||
});
|
||||
expect(client.constructor.name).toBe('OpenAIClient');
|
||||
expect((client as any).useOAuth).toBe(false);
|
||||
expect(getUseOAuth(client)).toBe(false);
|
||||
});
|
||||
|
||||
it('auth_mode oauth selects Anthropic auth_token without requiring api_key', async () => {
|
||||
@@ -338,7 +340,7 @@ describe('createClientFromConfig', () => {
|
||||
auth_mode: 'oauth',
|
||||
});
|
||||
expect(client.constructor.name).toBe('OpenAIClient');
|
||||
expect((client as any).useOAuth).toBe(true);
|
||||
expect(getUseOAuth(client)).toBe(true);
|
||||
} finally {
|
||||
process.env.HOME = originalHome;
|
||||
}
|
||||
@@ -407,7 +409,7 @@ describe('createAutoFallbackClient', () => {
|
||||
model: 'claude-sonnet-4-20250514',
|
||||
});
|
||||
expect(client).toBeDefined();
|
||||
expect((client as any).constructor.name).toBe('GitHubModelsClient');
|
||||
expect(getConstructorName(client)).toBe('GitHubModelsClient');
|
||||
});
|
||||
|
||||
it('returns undefined for non-anthropic providers', async () => {
|
||||
|
||||
Reference in New Issue
Block a user