mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 13:34:15 -07:00
add absolute file path description for windows (#12007)
This commit is contained in:
@@ -22,6 +22,14 @@ vi.mock('../telemetry/loggers.js', () => ({
|
||||
logFileOperation: vi.fn(),
|
||||
}));
|
||||
|
||||
interface ReadFileParameterSchema {
|
||||
properties: {
|
||||
absolute_path: {
|
||||
description: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
describe('ReadFileTool', () => {
|
||||
let tempRootDir: string;
|
||||
let tool: ReadFileTool;
|
||||
@@ -196,6 +204,38 @@ describe('ReadFileTool', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('constructor', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('should use windows-style path examples on windows', () => {
|
||||
vi.spyOn(process, 'platform', 'get').mockReturnValue('win32');
|
||||
|
||||
const tool = new ReadFileTool({} as unknown as Config);
|
||||
const schema = tool.schema;
|
||||
expect(
|
||||
(schema.parametersJsonSchema as ReadFileParameterSchema).properties
|
||||
.absolute_path.description,
|
||||
).toBe(
|
||||
"The absolute path to the file to read (e.g., 'C:\\Users\\project\\file.txt'). Relative paths are not supported. You must provide an absolute path.",
|
||||
);
|
||||
});
|
||||
|
||||
it('should use unix-style path examples on non-windows platforms', () => {
|
||||
vi.spyOn(process, 'platform', 'get').mockReturnValue('linux');
|
||||
|
||||
const tool = new ReadFileTool({} as unknown as Config);
|
||||
const schema = tool.schema;
|
||||
expect(
|
||||
(schema.parametersJsonSchema as ReadFileParameterSchema).properties
|
||||
.absolute_path.description,
|
||||
).toBe(
|
||||
"The absolute path to the file to read (e.g., '/home/user/project/file.txt'). Relative paths are not supported. You must provide an absolute path.",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('execute', () => {
|
||||
it('should return error if file does not exist', async () => {
|
||||
const filePath = path.join(tempRootDir, 'nonexistent.txt');
|
||||
|
||||
Reference in New Issue
Block a user