MCPcopy Create free account
hub / github.com/anomalyco/opencode / requestDiff

Function requestDiff

packages/http-recorder/src/matching.ts:73–93  ·  view source on GitHub ↗
(expected: RequestSnapshot, received: RequestSnapshot)

Source from the content-addressed store, hash-verified

71 })
72
73export const requestDiff = (expected: RequestSnapshot, received: RequestSnapshot): ReadonlyArray<string> => {
74 const lines: string[] = []
75 if (expected.method !== received.method) {
76 lines.push("method:", ` expected ${expected.method}, received ${received.method}`)
77 }
78 if (expected.url !== received.url) {
79 lines.push("url:", ` expected ${expected.url}`, ` received ${received.url}`)
80 }
81 const headers = headerDiffs(expected.headers, received.headers)
82 if (headers.length > 0) lines.push("headers:", ...headers.slice(0, 8))
83 const expectedBody = jsonBody(expected.body)
84 const receivedBody = jsonBody(received.body)
85 const body =
86 expectedBody !== undefined && receivedBody !== undefined
87 ? valueDiffs(expectedBody, receivedBody).map((line) => ` ${line}`)
88 : expected.body === received.body
89 ? []
90 : [` expected ${safeText(expected.body)}, received ${safeText(received.body)}`]
91 if (body.length > 0) lines.push("body:", ...body)
92 return lines
93}
94
95export const selectSequential = (
96 interactions: ReadonlyArray<HttpInteraction>,

Callers 1

selectSequentialFunction · 0.85

Calls 5

headerDiffsFunction · 0.85
jsonBodyFunction · 0.85
valueDiffsFunction · 0.85
safeTextFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected