mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
chore: sync gemini-cli v0.1.19
This commit is contained in:
@@ -25,6 +25,7 @@ vi.mock('../utils/summarizer.js');
|
||||
|
||||
import { isCommandAllowed } from '../utils/shell-utils.js';
|
||||
import { ShellTool } from './shell.js';
|
||||
import { ToolErrorType } from './tool-error.js';
|
||||
import { type Config } from '../config/config.js';
|
||||
import {
|
||||
type ShellExecutionResult,
|
||||
@@ -208,6 +209,42 @@ describe('ShellTool', () => {
|
||||
expect(result.llmContent).not.toContain('pgrep');
|
||||
});
|
||||
|
||||
it('should return error with error property for invalid parameters', async () => {
|
||||
const result = await shellTool.execute(
|
||||
{ command: '' }, // Empty command is invalid
|
||||
mockAbortSignal,
|
||||
);
|
||||
|
||||
expect(result.llmContent).toContain(
|
||||
'Could not execute command due to invalid parameters:',
|
||||
);
|
||||
expect(result.returnDisplay).toBe('Command cannot be empty.');
|
||||
expect(result.error).toEqual({
|
||||
message: 'Command cannot be empty.',
|
||||
type: ToolErrorType.INVALID_TOOL_PARAMS,
|
||||
});
|
||||
});
|
||||
|
||||
it('should return error with error property for invalid directory', async () => {
|
||||
vi.mocked(fs.existsSync).mockReturnValue(false);
|
||||
const result = await shellTool.execute(
|
||||
{ command: 'ls', directory: 'nonexistent' },
|
||||
mockAbortSignal,
|
||||
);
|
||||
|
||||
expect(result.llmContent).toContain(
|
||||
'Could not execute command due to invalid parameters:',
|
||||
);
|
||||
expect(result.returnDisplay).toBe(
|
||||
"Directory 'nonexistent' is not a registered workspace directory.",
|
||||
);
|
||||
expect(result.error).toEqual({
|
||||
message:
|
||||
"Directory 'nonexistent' is not a registered workspace directory.",
|
||||
type: ToolErrorType.INVALID_TOOL_PARAMS,
|
||||
});
|
||||
});
|
||||
|
||||
it('should summarize output when configured', async () => {
|
||||
(mockConfig.getSummarizeToolOutputConfig as Mock).mockReturnValue({
|
||||
[shellTool.name]: { tokenBudget: 1000 },
|
||||
|
||||
Reference in New Issue
Block a user