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

Function TestErrorf

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

Source from the content-addressed store, hash-verified

47}
48
49func TestErrorf(t *testing.T) {
50 code := 400
51 errMsg := "this is an error"
52 expectedHTTPResponse := &HTTPResponse{
53 Code: int32(code),
54 Body: []byte(errMsg),
55 }
56 err := Error(code, errMsg)
57 stat, ok := status.FromError(err)
58 require.True(t, ok)
59 require.Equal(t, code, int(stat.Code()))
60 require.Equal(t, errMsg, stat.Message())
61 checkDetailAsHTTPResponse(t, expectedHTTPResponse, stat)
62}
63
64func TestErrorFromHTTPResponse(t *testing.T) {
65 var code int32 = 400

Callers

nothing calls this directly

Calls 4

ErrorFunction · 0.85
MessageMethod · 0.80
EqualMethod · 0.45

Tested by

no test coverage detected