MCPcopy Index your code
hub / github.com/coder/mux / createMockExecResult

Function createMockExecResult

src/node/services/coderService.test.ts:22–38  ·  view source on GitHub ↗
(
  result: Promise<{ stdout: string; stderr: string }>
)

Source from the content-addressed store, hash-verified

20// Minimal mock that satisfies the interface used by CoderService
21// Uses cast via `unknown` because we only implement the subset actually used by tests
22function createMockExecResult(
23 result: Promise<{ stdout: string; stderr: string }>
24): ReturnType<typeof disposableExec.execFileAsync> {
25 // Prevent Bun from surfacing immediate Promise.reject() as an unhandled rejection
26 // before CoderService awaits proc.result.
27 void result.catch(noop);
28
29 const mock = {
30 result,
31 get promise() {
32 return result;
33 },
34 child: {}, // not used by CoderService
35 [Symbol.dispose]: noop,
36 };
37 return mock as unknown as ReturnType<typeof disposableExec.execFileAsync>;
38}
39
40function mockExecOk(stdout: string, stderr = ""): void {
41 execFileAsyncSpy?.mockReturnValue(createMockExecResult(Promise.resolve({ stdout, stderr })));

Callers 6

mockExecOkFunction · 0.70
mockExecErrorFunction · 0.70
mockVersionAndWhoamiFunction · 0.70
mockTokenCommandsFunction · 0.70
mockPrefetchCallsFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected