Add embedding config default regression tests
--- Build: pass | Tests: pass — 2451 passed (182 files)
This commit is contained in:
parent
57fb7a8aa5
commit
ff9e086a98
1 changed files with 43 additions and 0 deletions
|
|
@ -18,6 +18,10 @@ const ENV_KEYS = [
|
|||
'OPENROUTER_API_KEY',
|
||||
'DEEPSEEK_API_KEY',
|
||||
'OPENAI_API_KEY',
|
||||
'EMBED_BASE_URL',
|
||||
'EMBED_API_KEY',
|
||||
'EMBED_MODEL',
|
||||
'EMBED_DIMENSIONS',
|
||||
] as const;
|
||||
|
||||
function resetIdentityEnv(): void {
|
||||
|
|
@ -168,4 +172,43 @@ describe('config identity', () => {
|
|||
});
|
||||
expect(config.resolveProviderApiKey('unknown')).toBeNull();
|
||||
});
|
||||
|
||||
it('falls back to local embeddings when the env file omits EMBED_BASE_URL', async () => {
|
||||
vi.doMock('./env.js', async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import('./env.js')>('./env.js');
|
||||
return {
|
||||
...actual,
|
||||
readEnvFile: () => ({}),
|
||||
};
|
||||
});
|
||||
|
||||
const config = await import('./config.js');
|
||||
|
||||
expect(config.EMBED_BASE_URL).toBe('http://localhost:8080/v1');
|
||||
expect(config.EMBED_MODEL).toBe('BAAI/bge-m3');
|
||||
expect(config.EMBED_API_KEY).toBe('');
|
||||
|
||||
vi.doUnmock('./env.js');
|
||||
});
|
||||
|
||||
it('derives OpenRouter embedding settings from an env-file OpenRouter key', async () => {
|
||||
vi.doMock('./env.js', async () => {
|
||||
const actual =
|
||||
await vi.importActual<typeof import('./env.js')>('./env.js');
|
||||
return {
|
||||
...actual,
|
||||
readEnvFile: () => ({ OPENROUTER_API_KEY: 'or-key' }),
|
||||
};
|
||||
});
|
||||
|
||||
const config = await import('./config.js');
|
||||
|
||||
expect(config.OPENROUTER_API_KEY).toBe('or-key');
|
||||
expect(config.EMBED_BASE_URL).toBe('https://openrouter.ai/api/v1');
|
||||
expect(config.EMBED_MODEL).toBe('BAAI/bge-m3');
|
||||
expect(config.EMBED_API_KEY).toBe('or-key');
|
||||
|
||||
vi.doUnmock('./env.js');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue