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

Function TestTextDecoder

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

Source from the content-addressed store, hash-verified

35)
36
37func TestTextDecoder(t *testing.T) {
38 var (
39 ts = model.Now()
40 in = `
41# Only a quite simple scenario with two metric families.
42# More complicated tests of the parser itself can be found in the text package.
43# TYPE mf2 counter
44mf2 3
45mf1{label="value1"} -3.14 123456
46mf1{label="value2"} 42
47mf2 4
48`
49 out = model.Vector{
50 &model.Sample{
51 Metric: model.Metric{
52 model.MetricNameLabel: "mf1",
53 "label": "value1",
54 },
55 Value: -3.14,
56 Timestamp: 123456,
57 },
58 &model.Sample{
59 Metric: model.Metric{
60 model.MetricNameLabel: "mf1",
61 "label": "value2",
62 },
63 Value: 42,
64 Timestamp: ts,
65 },
66 &model.Sample{
67 Metric: model.Metric{
68 model.MetricNameLabel: "mf2",
69 },
70 Value: 3,
71 Timestamp: ts,
72 },
73 &model.Sample{
74 Metric: model.Metric{
75 model.MetricNameLabel: "mf2",
76 },
77 Value: 4,
78 Timestamp: ts,
79 },
80 }
81 )
82
83 dec := &SampleDecoder{
84 Dec: &textDecoder{
85 s: model.UTF8Validation,
86 r: strings.NewReader(in),
87 },
88 Opts: &DecodeOptions{
89 Timestamp: ts,
90 },
91 }
92 var all model.Vector
93 for {
94 var smpls model.Vector

Callers

nothing calls this directly

Calls 2

DecodeMethod · 0.95
NowFunction · 0.92

Tested by

no test coverage detected