MCPcopy
hub / github.com/garrytan/gstack / makeStubFetch

Function makeStubFetch

design/test/variants-retry-after.test.ts:30–42  ·  view source on GitHub ↗
(
  responses: Response[],
  calls: CallRecord[],
)

Source from the content-addressed store, hash-verified

28}
29
30function makeStubFetch(
31 responses: Response[],
32 calls: CallRecord[],
33): typeof globalThis.fetch {
34 let idx = 0;
35 return (async (_input: any, _init?: any) => {
36 calls.push({ ts: Date.now() });
37 const response = responses[idx];
38 if (!response) throw new Error(`stub fetch: no response for call ${idx + 1}`);
39 idx++;
40 return response;
41 }) as typeof globalThis.fetch;
42}
43
44describe("generateVariant Retry-After handling", () => {
45 let tmpDir: string;

Callers 1

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected