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

Function TestResponse

pkg/querier/tripperware/queryrange/query_range_test.go:99–315  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

97}
98
99func TestResponse(t *testing.T) {
100 t.Parallel()
101 r := *parsedResponse
102 rWithWarnings := *parsedResponseWithWarnings
103 rWithInfos := *parsedResponseWithInfos
104 testCases := []struct {
105 promBody *tripperware.PrometheusResponse
106 jsonBody string
107 expectedDecodeErr error
108 cancelCtxBeforeDecode bool
109 isProtobuf bool
110 }{
111 {
112 promBody: &tripperware.PrometheusResponse{
113 Status: "success",
114 Data: tripperware.PrometheusData{
115 ResultType: model.ValMatrix.String(),
116 Result: tripperware.PrometheusQueryResult{
117 Result: &tripperware.PrometheusQueryResult_Matrix{
118 Matrix: &tripperware.Matrix{
119 SampleStreams: []tripperware.SampleStream{
120 {
121 Labels: []cortexpb.LabelAdapter{
122 {Name: "foo", Value: "bar"},
123 },
124 Samples: []cortexpb.Sample{
125 {Value: 137, TimestampMs: 1536673680000},
126 {Value: 137, TimestampMs: 1536673780000},
127 },
128 },
129 },
130 },
131 },
132 },
133 },
134 },
135 jsonBody: responseBody,
136 isProtobuf: true,
137 },
138 {
139 promBody: &r,
140 jsonBody: responseBody,
141 isProtobuf: false,
142 },
143 {
144 promBody: &tripperware.PrometheusResponse{
145 Status: "success",
146 Warnings: []string{"test-warn"},
147 Data: tripperware.PrometheusData{
148 ResultType: model.ValMatrix.String(),
149 Result: tripperware.PrometheusQueryResult{
150 Result: &tripperware.PrometheusQueryResult_Matrix{
151 Matrix: &tripperware.Matrix{
152 SampleStreams: []tripperware.SampleStream{
153 {
154 Labels: []cortexpb.LabelAdapter{
155 {Name: "foo", Value: "bar"},
156 },

Callers

nothing calls this directly

Calls 6

StringMethod · 0.65
RunMethod · 0.65
DecodeResponseMethod · 0.65
EqualMethod · 0.65
EncodeResponseMethod · 0.65
MarshalMethod · 0.45

Tested by

no test coverage detected