docs: updated config docs and tests

This commit is contained in:
2026-06-15 15:37:55 +01:00
parent bc9eb4e040
commit 5a078bb108
4 changed files with 249 additions and 8 deletions
+26 -2
View File
@@ -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.'
);
});