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

Function TestInstantQueryJsonCodec

pkg/ruler/frontend_client_test.go:48–160  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

46}
47
48func TestInstantQueryJsonCodec(t *testing.T) {
49 tests := []struct {
50 description string
51 responseBody string
52 expected promql.Vector
53 expectedErr error
54 }{
55 {
56 description: "empty vector",
57 responseBody: `{
58 "status": "success",
59 "data": {"resultType":"vector","result":[]}
60 }`,
61 expected: promql.Vector{},
62 expectedErr: nil,
63 },
64 {
65 description: "vector with series",
66 responseBody: `{
67 "status": "success",
68 "data": {
69 "resultType": "vector",
70 "result": [
71 {
72 "metric": {"foo":"bar"},
73 "value": [1724146338.123,"1.234"]
74 },
75 {
76 "metric": {"bar":"baz"},
77 "value": [1724146338.456,"5.678"]
78 }
79 ]
80 }
81 }`,
82 expected: promql.Vector{
83 {
84 Metric: labels.FromStrings("foo", "bar"),
85 T: 1724146338123,
86 F: 1.234,
87 },
88 {
89 Metric: labels.FromStrings("bar", "baz"),
90 T: 1724146338456,
91 F: 5.678,
92 },
93 },
94 expectedErr: nil,
95 },
96 {
97 description: "get scalar",
98 responseBody: `{
99 "status": "success",
100 "data": {"resultType":"scalar","result":[1724146338.123,"1.234"]}
101 }`,
102 expected: promql.Vector{
103 {
104 Metric: labels.EmptyLabels(),
105 T: 1724146338123,

Callers

nothing calls this directly

Calls 5

InstantQueryMethod · 0.95
mockHTTPGRPCClientFuncType · 0.85
NewFrontendClientFunction · 0.70
RunMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected