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

Function TestProtoDecoder

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…