MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestWriteError

Function TestWriteError

pkg/frontend/transport/handler_test.go:44–177  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

42}
43
44func TestWriteError(t *testing.T) {
45 for _, test := range []struct {
46 status int
47 err error
48 additionalHeaders http.Header
49 expectedErrResp util_api.Response
50 }{
51 {
52 http.StatusInternalServerError,
53 errors.New("unknown"),
54 http.Header{"User-Agent": []string{"Golang"}},
55 util_api.Response{
56 Status: "error",
57 ErrorType: v1.ErrServer,
58 Error: "unknown",
59 },
60 },
61 {
62 http.StatusInternalServerError,
63 errors.New("unknown"),
64 nil,
65 util_api.Response{
66 Status: "error",
67 ErrorType: v1.ErrServer,
68 Error: "unknown",
69 },
70 },
71 {
72 http.StatusGatewayTimeout,
73 context.DeadlineExceeded,
74 nil,
75 util_api.Response{
76 Status: "error",
77 ErrorType: v1.ErrTimeout,
78 Error: "",
79 },
80 },
81 {
82 StatusClientClosedRequest,
83 context.Canceled,
84 nil,
85 util_api.Response{
86 Status: "error",
87 ErrorType: v1.ErrCanceled,
88 Error: "",
89 },
90 },
91 {
92 StatusClientClosedRequest,
93 context.Canceled,
94 http.Header{"User-Agent": []string{"Golang"}},
95 util_api.Response{
96 Status: "error",
97 ErrorType: v1.ErrCanceled,
98 Error: "",
99 },
100 },
101 {

Callers

nothing calls this directly

Calls 6

writeErrorFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
ErrorMethod · 0.45
HeaderMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected