(t *testing.T)
| 69 | } |
| 70 | |
| 71 | func TestStatusCode(t *testing.T) { |
| 72 | var testCases = []struct { |
| 73 | name string |
| 74 | err error |
| 75 | expect int |
| 76 | }{ |
| 77 | { |
| 78 | name: "ok, HTTPError", |
| 79 | err: &HTTPError{Code: http.StatusNotFound}, |
| 80 | expect: http.StatusNotFound, |
| 81 | }, |
| 82 | { |
| 83 | name: "ok, sentinel error", |
| 84 | err: ErrNotFound, |
| 85 | expect: http.StatusNotFound, |
| 86 | }, |
| 87 | { |
| 88 | name: "ok, wrapped HTTPError", |
| 89 | err: fmt.Errorf("wrapped: %w", &HTTPError{Code: http.StatusTeapot}), |
| 90 | expect: http.StatusTeapot, |
| 91 | }, |
| 92 | { |
| 93 | name: "nok, normal error", |
| 94 | err: errors.New("error"), |
| 95 | expect: 0, |
| 96 | }, |
| 97 | { |
| 98 | name: "nok, nil", |
| 99 | err: nil, |
| 100 | expect: 0, |
| 101 | }, |
| 102 | } |
| 103 | |
| 104 | for _, tc := range testCases { |
| 105 | t.Run(tc.name, func(t *testing.T) { |
| 106 | assert.Equal(t, tc.expect, StatusCode(tc.err)) |
| 107 | }) |
| 108 | } |
| 109 | } |
| 110 | |
| 111 | func TestResolveResponseStatus(t *testing.T) { |
| 112 | someErr := errors.New("some error") |
nothing calls this directly
no test coverage detected
searching dependent graphs…