diff options
| author | joshualitt <[email protected]> | 2025-08-21 14:40:18 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-21 21:40:18 +0000 |
| commit | ec41b8db8e714867ea354c29c07f009cd837ac23 (patch) | |
| tree | 4bb01ac90a25d6d82cfc005d68aae336be192744 /packages/core/src/tools/grep.test.ts | |
| parent | 299bf58309a0950ac81ae051b02ec64463ebd153 (diff) | |
feat(core): Annotate remaining error paths in tools with type. (#6699)
Diffstat (limited to 'packages/core/src/tools/grep.test.ts')
| -rw-r--r-- | packages/core/src/tools/grep.test.ts | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/packages/core/src/tools/grep.test.ts b/packages/core/src/tools/grep.test.ts index 4bb59115..a152c88c 100644 --- a/packages/core/src/tools/grep.test.ts +++ b/packages/core/src/tools/grep.test.ts @@ -11,6 +11,10 @@ import fs from 'fs/promises'; import os from 'os'; import { Config } from '../config/config.js'; import { createMockWorkspaceContext } from '../test-utils/mockWorkspaceContext.js'; +import { ToolErrorType } from './tool-error.js'; +import * as glob from 'glob'; + +vi.mock('glob', { spy: true }); // Mock the child_process module to control grep/git grep behavior vi.mock('child_process', () => ({ @@ -223,6 +227,15 @@ describe('GrepTool', () => { /params must have required property 'pattern'/, ); }); + + it('should return a GREP_EXECUTION_ERROR on failure', async () => { + vi.mocked(glob.globStream).mockRejectedValue(new Error('Glob failed')); + const params: GrepToolParams = { pattern: 'hello' }; + const invocation = grepTool.build(params); + const result = await invocation.execute(abortSignal); + expect(result.error?.type).toBe(ToolErrorType.GREP_EXECUTION_ERROR); + vi.mocked(glob.globStream).mockReset(); + }); }); describe('multi-directory workspace', () => { |
