MCPcopy Create free account
hub / github.com/akash-network/provider / TestStatusCodeFrom

Function TestStatusCodeFrom

utils/httperror/httperror_test.go:11–27  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func 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}

Callers

nothing calls this directly

Calls 3

NewHttpErrorFunction · 0.85
StatusCodeFromFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected