Auth First Run (#1207)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
Co-authored-by: N. Taylor Mullen <ntaylormullen@google.com>
This commit is contained in:
matt korwel
2025-06-19 16:52:22 -07:00
committed by GitHub
parent c48fcaa8c3
commit 04518b52c0
37 changed files with 636 additions and 349 deletions

View File

@@ -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);