test(opencode): 補上 OpenCode server provider 測試
This commit is contained in:
@@ -8,6 +8,8 @@ const ENV_KEYS = [
|
||||
'GEMINI_API_KEY', 'GEMINI_BASE_URL', 'GEMINI_MODEL',
|
||||
'OLLAMA_BASE_URL', 'OLLAMA_MODEL',
|
||||
'AMAZONQ_API_KEY', 'AMAZONQ_BASE_URL', 'AMAZONQ_MODEL',
|
||||
'OPENCODE_BASE_URL', 'OPENCODE_MODEL', 'OPENCODE_PROVIDER',
|
||||
'OPENCODE_SERVER_USERNAME', 'OPENCODE_SERVER_PASSWORD',
|
||||
];
|
||||
|
||||
let saved = {};
|
||||
@@ -84,6 +86,24 @@ describe('getLLMConfig', () => {
|
||||
assert.equal(cfg.model, 'my-amazon-model');
|
||||
});
|
||||
|
||||
it('detects opencode server with gemini defaults', () => {
|
||||
process.env.OPENCODE_BASE_URL = 'http://opencode.local:4096';
|
||||
const cfg = getLLMConfig();
|
||||
assert.equal(cfg.provider, 'opencode');
|
||||
assert.deepEqual(cfg.apiKeys, ['opencode']);
|
||||
assert.equal(cfg.baseURL, 'http://opencode.local:4096');
|
||||
assert.equal(cfg.model, 'gemini-2.5-flash');
|
||||
});
|
||||
|
||||
it('detects opencode server with custom model', () => {
|
||||
process.env.OPENCODE_BASE_URL = 'http://opencode.local:4096';
|
||||
process.env.OPENCODE_MODEL = 'google/gemini-2.5-pro';
|
||||
const cfg = getLLMConfig();
|
||||
assert.equal(cfg.provider, 'opencode');
|
||||
assert.equal(cfg.baseURL, 'http://opencode.local:4096');
|
||||
assert.equal(cfg.model, 'google/gemini-2.5-pro');
|
||||
});
|
||||
|
||||
it('openai takes priority over gemini when both set', () => {
|
||||
process.env.OPENAI_API_KEY = 'sk-test';
|
||||
process.env.GEMINI_API_KEY = 'gemini-key';
|
||||
|
||||
Reference in New Issue
Block a user