MCPcopy
hub / github.com/TanStack/ai / makeFakeHandle

Function makeFakeHandle

packages/ai-claude-code/tests/projection.test.ts:42–70  ·  view source on GitHub ↗

Build a fake handle that records writes/execs and tracks existing paths.

(execResult: ExecResult)

Source from the content-addressed store, hash-verified

40
41/** Build a fake handle that records writes/execs and tracks existing paths. */
42function makeFakeHandle(execResult: ExecResult): FakeHandle {
43 const writes = new Map<string, string>()
44 const execs: Array<RecordedExec> = []
45 const existing = new Set<string>()
46 const dirs = new Set<string>()
47
48 const handle = {
49 fs: {
50 write: (path: string, data: string | Uint8Array) => {
51 writes.set(path, typeof data === 'string' ? data : '')
52 existing.add(path)
53 return Promise.resolve()
54 },
55 exists: (path: string) => Promise.resolve(existing.has(path)),
56 mkdir: (path: string) => {
57 dirs.add(path)
58 return Promise.resolve()
59 },
60 },
61 process: {
62 exec: (command: string, options?: { cwd?: string }) => {
63 execs.push({ command, cwd: options?.cwd })
64 return Promise.resolve(execResult)
65 },
66 },
67 } as unknown as SandboxHandle
68
69 return { handle, writes, execs, existing }
70}
71
72const ROOT = '/workspace'
73const MARKER = `${ROOT}/.tanstack-projected-abc123`

Callers 1

projection.test.tsFile · 0.70

Calls 4

resolveMethod · 0.80
hasMethod · 0.80
setMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected