diff options
| author | Yuki Okita <[email protected]> | 2025-08-20 10:55:47 +0900 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-20 01:55:47 +0000 |
| commit | 21c6480b65528a98ac0e1e3855f3c78c1f9b7cbe (patch) | |
| tree | 5555ec429209e87e0c21483c9e5fddd53ac01dbc /packages/cli/src/ui/hooks/useShellHistory.test.ts | |
| parent | 1049d388451120587a8643a401fd71430a8cd5fe (diff) | |
Refac: Centralize storage file management (#4078)
Co-authored-by: Taylor Mullen <[email protected]>
Diffstat (limited to 'packages/cli/src/ui/hooks/useShellHistory.test.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useShellHistory.test.ts | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/packages/cli/src/ui/hooks/useShellHistory.test.ts b/packages/cli/src/ui/hooks/useShellHistory.test.ts index 3e2c2dd8..f0d8586c 100644 --- a/packages/cli/src/ui/hooks/useShellHistory.test.ts +++ b/packages/cli/src/ui/hooks/useShellHistory.test.ts @@ -11,9 +11,41 @@ import * as path from 'path'; import * as os from 'os'; import * as crypto from 'crypto'; -vi.mock('fs/promises'); +vi.mock('fs/promises', () => ({ + readFile: vi.fn(), + writeFile: vi.fn(), + mkdir: vi.fn(), +})); vi.mock('os'); vi.mock('crypto'); +vi.mock('fs', async (importOriginal) => { + const actualFs = await importOriginal<typeof import('fs')>(); + return { + ...actualFs, + mkdirSync: vi.fn(), + }; +}); +vi.mock('@google/gemini-cli-core', () => { + class Storage { + getProjectTempDir(): string { + return path.join('/test/home/', '.gemini', 'tmp', 'mocked_hash'); + } + getHistoryFilePath(): string { + return path.join( + '/test/home/', + '.gemini', + 'tmp', + 'mocked_hash', + 'shell_history', + ); + } + } + return { + isNodeError: (err: unknown): err is NodeJS.ErrnoException => + typeof err === 'object' && err !== null && 'code' in err, + Storage, + }; +}); const MOCKED_PROJECT_ROOT = '/test/project'; const MOCKED_HOME_DIR = '/test/home'; |
