mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-15 15:50:35 -07:00
feat(plan): add core logic and exit_plan_mode tool definition (#18110)
This commit is contained in:
@@ -34,6 +34,8 @@ import {
|
||||
readWasmBinaryFromDisk,
|
||||
saveTruncatedToolOutput,
|
||||
formatTruncatedToolOutput,
|
||||
getRealPath,
|
||||
isEmpty,
|
||||
} from './fileUtils.js';
|
||||
import { StandardFileSystemService } from '../services/fileSystemService.js';
|
||||
|
||||
@@ -172,6 +174,47 @@ describe('fileUtils', () => {
|
||||
);
|
||||
});
|
||||
|
||||
describe('getRealPath', () => {
|
||||
it('should resolve a real path for an existing file', () => {
|
||||
const testFile = path.join(tempRootDir, 'real.txt');
|
||||
actualNodeFs.writeFileSync(testFile, 'content');
|
||||
expect(getRealPath(testFile)).toBe(actualNodeFs.realpathSync(testFile));
|
||||
});
|
||||
|
||||
it('should return absolute resolved path for a non-existent file', () => {
|
||||
const ghostFile = path.join(tempRootDir, 'ghost.txt');
|
||||
expect(getRealPath(ghostFile)).toBe(path.resolve(ghostFile));
|
||||
});
|
||||
|
||||
it('should resolve symbolic links', () => {
|
||||
const targetFile = path.join(tempRootDir, 'target.txt');
|
||||
const linkFile = path.join(tempRootDir, 'link.txt');
|
||||
actualNodeFs.writeFileSync(targetFile, 'content');
|
||||
actualNodeFs.symlinkSync(targetFile, linkFile);
|
||||
|
||||
expect(getRealPath(linkFile)).toBe(actualNodeFs.realpathSync(targetFile));
|
||||
});
|
||||
});
|
||||
|
||||
describe('isEmpty', () => {
|
||||
it('should return false for a non-empty file', async () => {
|
||||
const testFile = path.join(tempRootDir, 'full.txt');
|
||||
actualNodeFs.writeFileSync(testFile, 'some content');
|
||||
expect(await isEmpty(testFile)).toBe(false);
|
||||
});
|
||||
|
||||
it('should return true for an empty file', async () => {
|
||||
const testFile = path.join(tempRootDir, 'empty.txt');
|
||||
actualNodeFs.writeFileSync(testFile, ' ');
|
||||
expect(await isEmpty(testFile)).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true for a non-existent file (defensive)', async () => {
|
||||
const testFile = path.join(tempRootDir, 'ghost.txt');
|
||||
expect(await isEmpty(testFile)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('fileExists', () => {
|
||||
it('should return true if the file exists', async () => {
|
||||
const testFile = path.join(tempRootDir, 'exists.txt');
|
||||
|
||||
Reference in New Issue
Block a user