MCPcopy Index your code
hub / github.com/google/go-github / TestCompareHttpResponse

Function TestCompareHttpResponse

github/github_test.go:3454–3489  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3452}
3453
3454func TestCompareHttpResponse(t *testing.T) {
3455 t.Parallel()
3456 testcases := map[string]struct {
3457 h1 *http.Response
3458 h2 *http.Response
3459 expected bool
3460 }{
3461 "both are nil": {
3462 expected: true,
3463 },
3464 "both are non nil - same StatusCode": {
3465 expected: true,
3466 h1: &http.Response{StatusCode: 200},
3467 h2: &http.Response{StatusCode: 200},
3468 },
3469 "both are non nil - different StatusCode": {
3470 expected: false,
3471 h1: &http.Response{StatusCode: 200},
3472 h2: &http.Response{StatusCode: 404},
3473 },
3474 "one is nil, other is not": {
3475 expected: false,
3476 h2: &http.Response{},
3477 },
3478 }
3479
3480 for name, tc := range testcases {
3481 t.Run(name, func(t *testing.T) {
3482 t.Parallel()
3483 v := compareHTTPResponse(tc.h1, tc.h2)
3484 if tc.expected != v {
3485 t.Errorf("Expected %t, got %t for (%#v, %#v)", tc.expected, v, tc.h1, tc.h2)
3486 }
3487 })
3488 }
3489}
3490
3491func TestErrorResponse_Is(t *testing.T) {
3492 t.Parallel()

Callers

nothing calls this directly

Calls 2

compareHTTPResponseFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…