MCPcopy Create free account
hub / github.com/prometheus/common / TestProtoDecoder

Function TestProtoDecoder

expfmt/decode_test.go:103–369  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestProtoDecoder(t *testing.T) {
104 testTime := model.Now()
105
106 scenarios := []struct {
107 in string
108 expected model.Vector
109 fail bool
110 }{
111 {
112 in: "",
113 },
114 {
115 in: "\x8f\x01\n\rrequest_count\x12\x12Number of requests\x18\x00\"0\n#\n\x0fsome_!abel_name\x12\x10some_label_value\x1a\t\t\x00\x00\x00\x00\x00\x00E\xc0\"6\n)\n\x12another_label_name\x12\x13another_label_value\x1a\t\t\x00\x00\x00\x00\x00\x00U@",
116 fail: true,
117 },
118 {
119 in: "\x8f\x01\n\rrequest_count\x12\x12Number of requests\x18\x00\"0\n#\n\x0fsome_label_name\x12\x10some_label_value\x1a\t\t\x00\x00\x00\x00\x00\x00E\xc0\"6\n)\n\x12another_label_name\x12\x13another_label_value\x1a\t\t\x00\x00\x00\x00\x00\x00U@",
120 expected: model.Vector{
121 &model.Sample{
122 Metric: model.Metric{
123 model.MetricNameLabel: "request_count",
124 "some_label_name": "some_label_value",
125 },
126 Value: -42,
127 Timestamp: testTime,
128 },
129 &model.Sample{
130 Metric: model.Metric{
131 model.MetricNameLabel: "request_count",
132 "another_label_name": "another_label_value",
133 },
134 Value: 84,
135 Timestamp: testTime,
136 },
137 },
138 },
139 {
140 in: "\xb9\x01\n\rrequest_count\x12\x12Number of requests\x18\x02\"O\n#\n\x0fsome_label_name\x12\x10some_label_value\"(\x1a\x12\t\xaeG\xe1z\x14\xae\xef?\x11\x00\x00\x00\x00\x00\x00E\xc0\x1a\x12\t+\x87\x16\xd9\xce\xf7\xef?\x11\x00\x00\x00\x00\x00\x00U\xc0\"A\n)\n\x12another_label_name\x12\x13another_label_value\"\x14\x1a\x12\t\x00\x00\x00\x00\x00\x00\xe0?\x11\x00\x00\x00\x00\x00\x00$@",
141 expected: model.Vector{
142 &model.Sample{
143 Metric: model.Metric{
144 model.MetricNameLabel: "request_count_count",
145 "some_label_name": "some_label_value",
146 },
147 Value: 0,
148 Timestamp: testTime,
149 },
150 &model.Sample{
151 Metric: model.Metric{
152 model.MetricNameLabel: "request_count_sum",
153 "some_label_name": "some_label_value",
154 },
155 Value: 0,
156 Timestamp: testTime,
157 },
158 &model.Sample{
159 Metric: model.Metric{
160 model.MetricNameLabel: "request_count",

Callers

nothing calls this directly

Calls 2

DecodeMethod · 0.95
NowFunction · 0.92

Tested by

no test coverage detected