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

Function testTextParse

expfmt/text_parse_test.go:45–991  ·  view source on GitHub ↗
(t testing.TB)

Source from the content-addressed store, hash-verified

43}
44
45func testTextParse(t testing.TB) {
46 scenarios := []struct {
47 in string
48 out []*dto.MetricFamily
49 }{
50 // 0: Empty lines as input.
51 {
52 in: `
53
54`,
55 out: []*dto.MetricFamily{},
56 },
57 // 1: Minimal case.
58 {
59 in: `
60minimal_metric 1.234
61another_metric -3e3 103948
62# Even that:
63no_labels{} 3
64# HELP line for non-existing metric will be ignored.
65`,
66 out: []*dto.MetricFamily{
67 {
68 Name: proto.String("minimal_metric"),
69 Type: dto.MetricType_UNTYPED.Enum(),
70 Metric: []*dto.Metric{
71 {
72 Untyped: &dto.Untyped{
73 Value: proto.Float64(1.234),
74 },
75 },
76 },
77 },
78 {
79 Name: proto.String("another_metric"),
80 Type: dto.MetricType_UNTYPED.Enum(),
81 Metric: []*dto.Metric{
82 {
83 Untyped: &dto.Untyped{
84 Value: proto.Float64(-3e3),
85 },
86 TimestampMs: proto.Int64(103948),
87 },
88 },
89 },
90 {
91 Name: proto.String("no_labels"),
92 Type: dto.MetricType_UNTYPED.Enum(),
93 Metric: []*dto.Metric{
94 {
95 Untyped: &dto.Untyped{
96 Value: proto.Float64(3),
97 },
98 },
99 },
100 },
101 },
102 },

Callers 2

TestTextParseFunction · 0.85
BenchmarkTextParseFunction · 0.85

Calls 2

TextToMetricFamiliesMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected