mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 11:34:44 -07:00
feat(core,cli): enforce mandatory MessageBus injection (Phase 3 Hard Migration) (#15776)
This commit is contained in:
@@ -24,6 +24,7 @@ import { createMockWorkspaceContext } from '../test-utils/mockWorkspaceContext.j
|
||||
import type { ChildProcess } from 'node:child_process';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { downloadRipGrep } from '@joshua.litt/get-ripgrep';
|
||||
import { createMockMessageBus } from '../test-utils/mock-message-bus.js';
|
||||
// Mock dependencies for canUseRipgrep
|
||||
vi.mock('@joshua.litt/get-ripgrep', () => ({
|
||||
downloadRipGrep: vi.fn(),
|
||||
@@ -267,7 +268,7 @@ describe('RipGrepTool', () => {
|
||||
await fs.writeFile(ripgrepBinaryPath, '');
|
||||
storageSpy.mockImplementation(() => binDir);
|
||||
tempRootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'grep-tool-root-'));
|
||||
grepTool = new RipGrepTool(mockConfig);
|
||||
grepTool = new RipGrepTool(mockConfig, createMockMessageBus());
|
||||
|
||||
// Create some test files and directories
|
||||
await fs.writeFile(
|
||||
@@ -833,7 +834,10 @@ describe('RipGrepTool', () => {
|
||||
return mockProcess as unknown as ChildProcess;
|
||||
});
|
||||
|
||||
const multiDirGrepTool = new RipGrepTool(multiDirConfig);
|
||||
const multiDirGrepTool = new RipGrepTool(
|
||||
multiDirConfig,
|
||||
createMockMessageBus(),
|
||||
);
|
||||
const params: RipGrepToolParams = { pattern: 'world' };
|
||||
const invocation = multiDirGrepTool.build(params);
|
||||
const result = await invocation.execute(abortSignal);
|
||||
@@ -927,7 +931,10 @@ describe('RipGrepTool', () => {
|
||||
return mockProcess as unknown as ChildProcess;
|
||||
});
|
||||
|
||||
const multiDirGrepTool = new RipGrepTool(multiDirConfig);
|
||||
const multiDirGrepTool = new RipGrepTool(
|
||||
multiDirConfig,
|
||||
createMockMessageBus(),
|
||||
);
|
||||
|
||||
// Search only in the 'sub' directory of the first workspace
|
||||
const params: RipGrepToolParams = { pattern: 'world', dir_path: 'sub' };
|
||||
@@ -1656,7 +1663,10 @@ describe('RipGrepTool', () => {
|
||||
getDebugMode: () => false,
|
||||
getFileFilteringRespectGeminiIgnore: () => true,
|
||||
} as unknown as Config;
|
||||
const geminiIgnoreTool = new RipGrepTool(configWithGeminiIgnore);
|
||||
const geminiIgnoreTool = new RipGrepTool(
|
||||
configWithGeminiIgnore,
|
||||
createMockMessageBus(),
|
||||
);
|
||||
|
||||
mockSpawn.mockImplementationOnce(
|
||||
createMockSpawn({
|
||||
@@ -1693,7 +1703,10 @@ describe('RipGrepTool', () => {
|
||||
getDebugMode: () => false,
|
||||
getFileFilteringRespectGeminiIgnore: () => false,
|
||||
} as unknown as Config;
|
||||
const geminiIgnoreTool = new RipGrepTool(configWithoutGeminiIgnore);
|
||||
const geminiIgnoreTool = new RipGrepTool(
|
||||
configWithoutGeminiIgnore,
|
||||
createMockMessageBus(),
|
||||
);
|
||||
|
||||
mockSpawn.mockImplementationOnce(
|
||||
createMockSpawn({
|
||||
@@ -1816,7 +1829,10 @@ describe('RipGrepTool', () => {
|
||||
getDebugMode: () => false,
|
||||
} as unknown as Config;
|
||||
|
||||
const multiDirGrepTool = new RipGrepTool(multiDirConfig);
|
||||
const multiDirGrepTool = new RipGrepTool(
|
||||
multiDirConfig,
|
||||
createMockMessageBus(),
|
||||
);
|
||||
const params: RipGrepToolParams = { pattern: 'testPattern' };
|
||||
const invocation = multiDirGrepTool.build(params);
|
||||
expect(invocation.getDescription()).toBe("'testPattern' within ./");
|
||||
|
||||
Reference in New Issue
Block a user