(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func 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, |
nothing calls this directly
no test coverage detected