diff options
Diffstat (limited to 'packages/core/src/config/config.test.ts')
| -rw-r--r-- | packages/core/src/config/config.test.ts | 47 |
1 files changed, 42 insertions, 5 deletions
diff --git a/packages/core/src/config/config.test.ts b/packages/core/src/config/config.test.ts index 10fd814f..8a9f038c 100644 --- a/packages/core/src/config/config.test.ts +++ b/packages/core/src/config/config.test.ts @@ -42,6 +42,21 @@ vi.mock('../tools/memoryTool', () => ({ GEMINI_CONFIG_DIR: '.gemini', })); +vi.mock('../core/contentGenerator.js', async (importOriginal) => { + const actual = + await importOriginal<typeof import('../core/contentGenerator.js')>(); + return { + ...actual, + createContentGeneratorConfig: vi.fn(), + }; +}); + +vi.mock('../core/client.js', () => ({ + GeminiClient: vi.fn().mockImplementation(() => ({ + // Mock any methods on GeminiClient that might be used. + })), +})); + vi.mock('../telemetry/index.js', async (importOriginal) => { const actual = await importOriginal<typeof import('../telemetry/index.js')>(); return { @@ -51,7 +66,6 @@ vi.mock('../telemetry/index.js', async (importOriginal) => { }); describe('Server Config (config.ts)', () => { - const API_KEY = 'server-api-key'; const MODEL = 'gemini-pro'; const SANDBOX: SandboxConfig = { command: 'docker', @@ -67,10 +81,6 @@ describe('Server Config (config.ts)', () => { const SESSION_ID = 'test-session-id'; const baseParams: ConfigParameters = { cwd: '/tmp', - contentGeneratorConfig: { - apiKey: API_KEY, - model: MODEL, - }, embeddingModel: EMBEDDING_MODEL, sandbox: SANDBOX, targetDir: TARGET_DIR, @@ -80,6 +90,7 @@ describe('Server Config (config.ts)', () => { userMemory: USER_MEMORY, telemetry: TELEMETRY_SETTINGS, sessionId: SESSION_ID, + model: MODEL, }; beforeEach(() => { @@ -87,6 +98,32 @@ describe('Server Config (config.ts)', () => { vi.clearAllMocks(); }); + // i can't get vi mocking to import in core. only in cli. can't fix it now. + // describe('refreshAuth', () => { + // it('should refresh auth and update config', async () => { + // const config = new Config(baseParams); + // const newModel = 'gemini-ultra'; + // const authType = AuthType.USE_GEMINI; + // const mockContentConfig = { + // model: newModel, + // apiKey: 'test-key', + // }; + + // (createContentGeneratorConfig as vi.Mock).mockResolvedValue( + // mockContentConfig, + // ); + + // await config.refreshAuth(authType); + + // expect(createContentGeneratorConfig).toHaveBeenCalledWith( + // newModel, + // authType, + // ); + // expect(config.getContentGeneratorConfig()).toEqual(mockContentConfig); + // expect(GeminiClient).toHaveBeenCalledWith(config); + // }); + // }); + it('Config constructor should store userMemory correctly', () => { const config = new Config(baseParams); |
