MCPcopy Index your code
hub / github.com/getsentry/XcodeBuildMCP / createMockToolHandlerContext

Function createMockToolHandlerContext

src/test-utils/test-helpers.ts:41–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

39}
40
41export function createMockToolHandlerContext(): {
42 ctx: ToolHandlerContext;
43 result: MockToolHandlerResult;
44 run: <T>(fn: () => Promise<T>) => Promise<T>;
45} {
46 const events: AnyFragment[] = [];
47 const attachments: ImageAttachment[] = [];
48 const session = createRenderSession('text');
49 const ctx: ToolHandlerContext = {
50 emit: (fragment: AnyFragment) => {
51 events.push(fragment);
52 session.emit(fragment);
53 },
54 attach: (image) => {
55 attachments.push(image);
56 session.attach(image);
57 },
58 };
59 const resultObj: MockToolHandlerResult = {
60 events,
61 attachments,
62 get nextStepParams() {
63 return ctx.nextStepParams;
64 },
65 text() {
66 return renderCliTextTranscript({
67 items: [],
68 structuredOutput: ctx.structuredOutput,
69 nextSteps: ctx.nextSteps,
70 });
71 },
72 isError() {
73 return ctx.structuredOutput?.result.didError === true;
74 },
75 };
76 return {
77 ctx,
78 result: resultObj,
79 run: async <T>(fn: () => Promise<T>): Promise<T> => {
80 return handlerContextStorage.run(ctx, fn);
81 },
82 };
83}
84
85export async function runToolLogic<T>(logic: () => Promise<T>): Promise<{
86 response: T;

Calls 4

createRenderSessionFunction · 0.90
pushMethod · 0.80
emitMethod · 0.80
attachMethod · 0.65

Tested by 11

runLogicFunction · 0.72
runListDevicesLogicFunction · 0.72
runListSimsLogicFunction · 0.72
runDragFunction · 0.72
runBatchFunction · 0.72
runLongPressFunction · 0.72
runTypeTextFunction · 0.72
runTouchFunction · 0.72
runSwipeFunction · 0.72
runTapFunction · 0.72
runWaitForUiFunction · 0.72