MCPcopy
hub / github.com/promptfoo/promptfoo / rateLimitedJsonResponse

Function rateLimitedJsonResponse

test/fetch.test.ts:1602–1614  ·  view source on GitHub ↗
(opts: {
      headers?: Headers;
      body?: unknown;
      statusText?: string;
    })

Source from the content-addressed store, hash-verified

1600
1601 describe('HttpRateLimitError classification', () => {
1602 function rateLimitedJsonResponse(opts: {
1603 headers?: Headers;
1604 body?: unknown;
1605 statusText?: string;
1606 }): Response {
1607 const text = JSON.stringify(opts.body ?? {});
1608 return createMockResponse({
1609 status: 429,
1610 statusText: opts.statusText ?? 'Too Many Requests',
1611 headers: opts.headers ?? new Headers(),
1612 text: () => Promise.resolve(text),
1613 });
1614 }
1615
1616 it('throws HttpRateLimitError when retries exhausted with rate-limit body code', async () => {
1617 const rateLimitResponse = rateLimitedJsonResponse({

Callers 1

fetch.test.tsFile · 0.85

Calls 2

createMockResponseFunction · 0.90
resolveMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…