10000 Add test for empty metadata, and the null byte. · ethervoid/client_python@c8c5a02 · GitHub
[go: up one dir, main page]

Skip to content

Commit c8c5a02

Browse files
committed
Add test for empty metadata, and the null byte.
Signed-off-by: Brian Brazil <brian.brazil@robustperception.io>
1 parent addb28c commit c8c5a02

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/openmetrics/test_parser.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,14 @@ def test_no_metadata(self):
173173
metric_family.add_sample("a", {}, 1)
174174
self.assertEqual([metric_family], list(families))
175175

176+
def test_empty_metadata(self):
177+
families = text_string_to_metric_families("""# HELP a
178+
# UNIT a
179+
# EOF
180+
""")
181+
metric_family = Metric("a", "", "untyped")
182+
self.assertEqual([metric_family], list(families))
183+
176184
def test_untyped(self):
177185
# https://github.com/prometheus/client_python/issues/79
178186
families = text_string_to_metric_families("""# HELP redis_connected_clients Redis connected clients
@@ -315,6 +323,14 @@ def test_escaping(self):
315323
metric_family.add_metric(["b\\a\\z"], 2)
316324
self.assertEqual([metric_family], list(families))
317325

326+
def test_null_byte(self):
327+
families = text_string_to_metric_families("""# TYPE a counter
328+
# HELP a he\0lp
329+
# EOF
330+
""")
331+
metric_family = CounterMetricFamily("a", "he\0lp")
332+
self.assertEqual([metric_family], list(families))
333+
318334
def test_timestamps(self):
319335
families = text_string_to_metric_families("""# TYPE a counter
320336
# HELP a help

0 commit comments

Comments
 (0)
0