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

Function TestProtoDecoder

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

Source from the content-addressed store, hash-verified

105}
106
107func TestProtoDecoder(t *testing.T) {
108 testTime := model.Now()
109
110 scenarios := []struct {
111 in string
112 expected model.Vector
113 legacyNameFail bool
114 fail bool
115 }{
116 {
117 in: "",
118 },
119 {
120 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@",
121 fail: true,
122 },
123 {
124 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@",
125 expected: model.Vector{
126 &model.Sample{
127 Metric: model.Metric{
128 model.MetricNameLabel: "request_count",
129 "some_label_name": "some_label_value",
130 },
131 Value: -42,
132 Timestamp: testTime,
133 },
134 &model.Sample{
135 Metric: model.Metric{
136 model.MetricNameLabel: "request_count",
137 "another_label_name": "another_label_value",
138 },
139 Value: 84,
140 Timestamp: testTime,
141 },
142 },
143 },
144 {
145 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$@",
146 expected: model.Vector{
147 &model.Sample{
148 Metric: model.Metric{
149 model.MetricNameLabel: "request_count_count",
150 "some_label_name": "some_label_value",
151 },
152 Value: 0,
153 Timestamp: testTime,
154 },
155 &model.Sample{
156 Metric: model.Metric{
157 model.MetricNameLabel: "request_count_sum",
158 "some_label_name": "some_label_value",
159 },
160 Value: 0,
161 Timestamp: testTime,
162 },
163 &model.Sample{
164 Metric: model.Metric{

Callers

nothing calls this directly

Calls 3

DecodeMethod · 0.95
NowFunction · 0.92
SampleValueTypeAlias · 0.92

Tested by

no test coverage detected