MCPcopy Index your code
hub / github.com/cortexproject/cortex / TestJsonDecode

Function TestJsonDecode

pkg/ruler/frontend_decoder_test.go:204–313  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

202}
203
204func TestJsonDecode(t *testing.T) {
205 tests := []struct {
206 description string
207 body string
208 expectedVector promql.Vector
209 expectedWarning Warnings
210 expectedErr error
211 }{
212 {
213 description: "empty vector",
214 body: `{
215 "status": "success",
216 "data": {"resultType":"vector","result":[]}
217 }`,
218 expectedVector: promql.Vector{},
219 expectedErr: nil,
220 expectedWarning: nil,
221 },
222 {
223 description: "vector with series",
224 body: `{
225 "status": "success",
226 "data": {
227 "resultType": "vector",
228 "result": [
229 {
230 "metric": {"foo":"bar"},
231 "value": [1724146338.123,"1.234"]
232 },
233 {
234 "metric": {"bar":"baz"},
235 "value": [1724146338.456,"5.678"]
236 }
237 ]
238 }
239 }`,
240 expectedVector: promql.Vector{
241 {
242 Metric: labels.FromStrings("foo", "bar"),
243 T: 1724146338123,
244 F: 1.234,
245 },
246 {
247 Metric: labels.FromStrings("bar", "baz"),
248 T: 1724146338456,
249 F: 5.678,
250 },
251 },
252 expectedErr: nil,
253 expectedWarning: nil,
254 },
255 {
256 description: "scalar",
257 body: `{
258 "status": "success",
259 "data": {"resultType":"scalar","result":[1724146338.123,"1.234"]}
260 }`,
261 expectedVector: promql.Vector{

Callers

nothing calls this directly

Calls 3

RunMethod · 0.65
DecodeMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected