(t *testing.T)
| 9 | ) |
| 10 | |
| 11 | func TestStatusCodeFrom(t *testing.T) { |
| 12 | tests := []struct { |
| 13 | name string |
| 14 | err error |
| 15 | want int |
| 16 | }{ |
| 17 | {"nil", nil, http.StatusOK}, |
| 18 | {"generic", errors.New("fail"), http.StatusInternalServerError}, |
| 19 | {"custom_503", NewHttpError(http.StatusServiceUnavailable, errors.New("refused")), http.StatusServiceUnavailable}, |
| 20 | {"custom_500", NewHttpError(500, errors.New("fail")), http.StatusInternalServerError}, |
| 21 | } |
| 22 | for _, tt := range tests { |
| 23 | t.Run(tt.name, func(t *testing.T) { |
| 24 | require.Equal(t, tt.want, StatusCodeFrom(tt.err)) |
| 25 | }) |
| 26 | } |
| 27 | } |
nothing calls this directly
no test coverage detected