MCPcopy
hub / github.com/github/github-mcp-server / andThen

Method andThen

pkg/github/helper_test.go:262–292  ·  view source on GitHub ↗
(responseHandler http.HandlerFunc)

Source from the content-addressed store, hash-verified

260}
261
262func (p *partialMock) andThen(responseHandler http.HandlerFunc) http.HandlerFunc {
263 p.t.Helper()
264 return func(w http.ResponseWriter, r *http.Request) {
265 if p.expectedPath != "" {
266 require.Equal(p.t, p.expectedPath, r.URL.Path)
267 }
268
269 if p.expectedQueryParams != nil {
270 require.Equal(p.t, len(p.expectedQueryParams), len(r.URL.Query()))
271 for k, v := range p.expectedQueryParams {
272 require.Equal(p.t, v, r.URL.Query().Get(k))
273 }
274 }
275
276 if p.expectedRequestBody != nil {
277 var unmarshaledRequestBody any
278 err := json.NewDecoder(r.Body).Decode(&unmarshaledRequestBody)
279 require.NoError(p.t, err)
280
281 require.Equal(p.t, p.expectedRequestBody, unmarshaledRequestBody)
282 }
283
284 if p.expectedHeaderContains != nil {
285 for k, v := range p.expectedHeaderContains {
286 require.Contains(p.t, r.Header.Get(k), v, "expected header %q to contain %q", k, v)
287 }
288 }
289
290 responseHandler(w, r)
291 }
292}
293
294// mockResponse is a helper function to create a mock HTTP response handler
295// that returns a specified status code and marshaled body.

Calls

no outgoing calls

Tested by

no test coverage detected