mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-13 03:20:33 -07:00
feat(cli): Partial threading of AgentLoopContext. (#22978)
This commit is contained in:
@@ -9,6 +9,7 @@ import { authCommand } from './authCommand.js';
|
||||
import { type CommandContext } from './types.js';
|
||||
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
|
||||
import { SettingScope } from '../../config/settings.js';
|
||||
import type { GeminiClient } from '@google/gemini-cli-core';
|
||||
|
||||
vi.mock('@google/gemini-cli-core', async () => {
|
||||
const actual = await vi.importActual('@google/gemini-cli-core');
|
||||
@@ -24,8 +25,10 @@ describe('authCommand', () => {
|
||||
beforeEach(() => {
|
||||
mockContext = createMockCommandContext({
|
||||
services: {
|
||||
config: {
|
||||
getGeminiClient: vi.fn(),
|
||||
agentContext: {
|
||||
geminiClient: {
|
||||
stripThoughtsFromHistory: vi.fn(),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -101,17 +104,19 @@ describe('authCommand', () => {
|
||||
const mockStripThoughts = vi.fn();
|
||||
const mockClient = {
|
||||
stripThoughtsFromHistory: mockStripThoughts,
|
||||
} as unknown as ReturnType<
|
||||
NonNullable<typeof mockContext.services.config>['getGeminiClient']
|
||||
>;
|
||||
|
||||
if (mockContext.services.config) {
|
||||
mockContext.services.config.getGeminiClient = vi.fn(() => mockClient);
|
||||
} as unknown as GeminiClient;
|
||||
if (mockContext.services.agentContext?.config) {
|
||||
mockContext.services.agentContext.config.getGeminiClient = vi.fn(
|
||||
() => mockClient,
|
||||
);
|
||||
}
|
||||
|
||||
await logoutCommand!.action!(mockContext, '');
|
||||
|
||||
expect(mockStripThoughts).toHaveBeenCalled();
|
||||
expect(
|
||||
mockContext.services.agentContext?.geminiClient
|
||||
.stripThoughtsFromHistory,
|
||||
).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should return logout action to signal explicit state change', async () => {
|
||||
@@ -123,7 +128,7 @@ describe('authCommand', () => {
|
||||
|
||||
it('should handle missing config gracefully', async () => {
|
||||
const logoutCommand = authCommand.subCommands?.[1];
|
||||
mockContext.services.config = null;
|
||||
mockContext.services.agentContext = null;
|
||||
|
||||
const result = await logoutCommand!.action!(mockContext, '');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user