mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-17 05:20:23 -07:00
tidying
This commit is contained in:
@@ -9,16 +9,21 @@ import {
|
||||
supersedeStaleSnapshots,
|
||||
SNAPSHOT_SUPERSEDED_PLACEHOLDER,
|
||||
} from './snapshotSuperseder.js';
|
||||
import type { GeminiChat } from '../../core/geminiChat.js';
|
||||
import type { GeminiChat, HistoryTurn } from '../../core/geminiChat.js';
|
||||
import type { Content } from '@google/genai';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
|
||||
/** Builds a minimal mock GeminiChat around a mutable history array. */
|
||||
function createMockChat(history: Content[]): GeminiChat {
|
||||
const getTurns = () => history.map((c) => ({ id: randomUUID(), content: c }));
|
||||
return {
|
||||
getHistory: vi.fn(() => [...history]),
|
||||
setHistory: vi.fn((newHistory: readonly Content[]) => {
|
||||
getHistoryTurns: vi.fn(() => getTurns()),
|
||||
setHistory: vi.fn((newHistory: ReadonlyArray<Content | HistoryTurn>) => {
|
||||
history.length = 0;
|
||||
history.push(...newHistory);
|
||||
for (const item of newHistory) {
|
||||
history.push('content' in item ? item.content : item);
|
||||
}
|
||||
}),
|
||||
} as unknown as GeminiChat;
|
||||
}
|
||||
|
||||
@@ -762,13 +762,13 @@ describe('LocalAgentExecutor', () => {
|
||||
const firstPart =
|
||||
'content' in history[0]
|
||||
? history[0].content.parts?.[0]
|
||||
: (history[0] as Content).parts?.[0];
|
||||
: history[0].parts?.[0];
|
||||
expect(firstPart?.text).toBe('Goal: TestGoal');
|
||||
|
||||
const secondPart =
|
||||
'content' in history[1]
|
||||
? history[1].content.parts?.[0]
|
||||
: (history[1] as Content).parts?.[0];
|
||||
: history[1].parts?.[0];
|
||||
expect(secondPart?.text).toBe('OK, starting on TestGoal.');
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
type FunctionCall,
|
||||
type FunctionDeclaration,
|
||||
} from '@google/genai';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { ToolRegistry } from '../tools/tool-registry.js';
|
||||
import { PromptRegistry } from '../prompts/prompt-registry.js';
|
||||
import { ResourceRegistry } from '../resources/resource-registry.js';
|
||||
|
||||
Reference in New Issue
Block a user