MCPcopy
hub / github.com/cli/cli / stubDiffRequest

Function stubDiffRequest

pkg/cmd/pr/diff/diff_test.go:440–458  ·  view source on GitHub ↗
(reg *httpmock.Registry, accept, diff string)

Source from the content-addressed store, hash-verified

438}
439
440func stubDiffRequest(reg *httpmock.Registry, accept, diff string) {
441 reg.Register(
442 func(req *http.Request) bool {
443 if !strings.EqualFold(req.Method, "GET") {
444 return false
445 }
446 if req.URL.EscapedPath() != "/repos/OWNER/REPO/pulls/123" {
447 return false
448 }
449 return req.Header.Get("Accept") == accept
450 },
451 func(req *http.Request) (*http.Response, error) {
452 return &http.Response{
453 StatusCode: 200,
454 Request: req,
455 Body: io.NopCloser(strings.NewReader(diff)),
456 }, nil
457 })
458}
459
460func Test_filterDiff(t *testing.T) {
461 rawDiff := fmt.Sprintf(testDiff, "", "", "", "")

Callers 1

Test_diffRunFunction · 0.85

Calls 2

GetMethod · 0.65
RegisterMethod · 0.45

Tested by

no test coverage detected