MCPcopy
hub / github.com/grafana/dskit / TestErrorFromHTTPResponse

Function TestErrorFromHTTPResponse

httpgrpc/httpgrpc_test.go:64–80  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

62}
63
64func TestErrorFromHTTPResponse(t *testing.T) {
65 var code int32 = 400
66 errMsg := "this is an error"
67 headers := []*Header{{Key: "X-Header", Values: []string{"a", "b", "c"}}}
68 resp := &HTTPResponse{
69 Code: code,
70 Headers: headers,
71 Body: []byte(errMsg),
72 }
73 err := ErrorFromHTTPResponse(resp)
74 require.Error(t, err)
75 stat, ok := status.FromError(err)
76 require.True(t, ok)
77 require.Equal(t, code, int32(stat.Code()))
78 require.Equal(t, errMsg, stat.Message())
79 checkDetailAsHTTPResponse(t, resp, stat)
80}
81
82func TestHTTPResponseFromError(t *testing.T) {
83 msgErr := "this is an error"

Callers

nothing calls this directly

Calls 5

ErrorFromHTTPResponseFunction · 0.85
MessageMethod · 0.80
ErrorMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected