(options: {
platform: NodeJS.Platform;
files?: Record<string, string>;
useFileHost?: boolean; // Use FileHost path in findGitRootFolder (for testing parent folder git root)
})
| 10 | import { nullLog } from '../spec-utils/log'; |
| 11 | |
| 12 | function createMockCLIHost(options: { |
| 13 | platform: NodeJS.Platform; |
| 14 | files?: Record<string, string>; |
| 15 | useFileHost?: boolean; // Use FileHost path in findGitRootFolder (for testing parent folder git root) |
| 16 | }): CLIHost { |
| 17 | const { platform, files = {}, useFileHost = false } = options; |
| 18 | const pathModule = platform === 'win32' ? path.win32 : path.posix; |
| 19 | const baseHost = { |
| 20 | type: 'local' as const, |
| 21 | platform, |
| 22 | arch: 'x64' as const, |
| 23 | path: pathModule, |
| 24 | cwd: platform === 'win32' ? 'C:\\' : '/', |
| 25 | env: {}, |
| 26 | ptyExec: () => { throw new Error('Not implemented'); }, |
| 27 | homedir: async () => platform === 'win32' ? 'C:\\Users\\test' : '/home/test', |
| 28 | tmpdir: async () => platform === 'win32' ? 'C:\\tmp' : '/tmp', |
| 29 | isFile: async (filepath: string) => filepath in files, |
| 30 | isFolder: async () => false, |
| 31 | readFile: async (filepath: string) => { |
| 32 | if (filepath in files) { |
| 33 | return Buffer.from(files[filepath]); |
| 34 | } |
| 35 | throw new Error(`File not found: ${filepath}`); |
| 36 | }, |
| 37 | writeFile: async () => { }, |
| 38 | rename: async () => { }, |
| 39 | mkdirp: async () => { }, |
| 40 | readDir: async () => [], |
| 41 | getUsername: async () => 'test', |
| 42 | toCommonURI: async () => undefined, |
| 43 | connect: () => { throw new Error('Not implemented'); }, |
| 44 | }; |
| 45 | // If useFileHost is true, don't include exec so findGitRootFolder uses the FileHost code path |
| 46 | if (useFileHost) { |
| 47 | return baseHost as unknown as CLIHost; |
| 48 | } |
| 49 | return { |
| 50 | ...baseHost, |
| 51 | exec: () => { throw new Error('Not implemented'); }, |
| 52 | } as CLIHost; |
| 53 | } |
| 54 | |
| 55 | function createWorkspace(rootFolderPath: string, configFolderPath?: string): Workspace { |
| 56 | return { |
no outgoing calls
no test coverage detected