docs: updated config docs and tests
This commit is contained in:
+26
-2
@@ -26,10 +26,34 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe('loadConfig', () => {
|
||||
it('throws when OPENAI_API_KEY is missing', () => {
|
||||
it('throws when OPENAI_API_KEY is missing and provider is openai', () => {
|
||||
delete process.env.OPENAI_API_KEY;
|
||||
delete process.env.CHATGPT_MCP_PROVIDER;
|
||||
expect(() => loadConfig()).toThrow(
|
||||
'Configuration error: OPENAI_API_KEY is missing.'
|
||||
'Configuration error: OPENAI_API_KEY is required for the openai provider.'
|
||||
);
|
||||
});
|
||||
|
||||
it('does not throw when OPENAI_API_KEY is missing and provider is manual', () => {
|
||||
delete process.env.OPENAI_API_KEY;
|
||||
setEnv({ CHATGPT_MCP_PROVIDER: 'manual' });
|
||||
const cfg = loadConfig();
|
||||
expect(cfg.chatgptMcpProvider).toBe('manual');
|
||||
expect(cfg.openaiApiKey).toBe(undefined);
|
||||
});
|
||||
|
||||
it('does not throw when OPENAI_API_KEY is missing and provider is ollama', () => {
|
||||
delete process.env.OPENAI_API_KEY;
|
||||
setEnv({ CHATGPT_MCP_PROVIDER: 'ollama' });
|
||||
const cfg = loadConfig();
|
||||
expect(cfg.chatgptMcpProvider).toBe('ollama');
|
||||
expect(cfg.openaiApiKey).toBe(undefined);
|
||||
});
|
||||
|
||||
it('still requires OPENAI_API_KEY for openai even when key is explicitly empty string', () => {
|
||||
setEnv({ CHATGPT_MCP_PROVIDER: 'openai', OPENAI_API_KEY: '' });
|
||||
expect(() => loadConfig()).toThrow(
|
||||
'Configuration error: OPENAI_API_KEY is required for the openai provider.'
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user