From 454f678c3bfcd931fdd0208c9d99e821af540b37 Mon Sep 17 00:00:00 2001 From: Lars Strojny Date: Thu, 19 Jan 2023 00:27:26 +0100 Subject: [PATCH] =?UTF-8?q?Let=E2=80=99s=20not=20lie=20in=20the=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/encoding/text.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/src/encoding/text.rs b/src/encoding/text.rs index cb7d4868..b760a685 100644 --- a/src/encoding/text.rs +++ b/src/encoding/text.rs @@ -753,7 +753,7 @@ def parse(input): } #[test] - fn metrics_are_sorted_by_registration_order() { + fn metrics_are_sorted_in_registration_order() { let mut registry = Registry::default(); let counter: Counter = Counter::default(); let another_counter: Counter = Counter::default(); @@ -774,20 +774,20 @@ def parse(input): } #[test] - fn metric_family_is_sorted_by_registration_order() { + fn metric_family_is_sorted_lexicographically() { let mut registry = Registry::default(); let gauge = Family::, Gauge>::default(); registry.register("my_gauge", "My gauge", gauge.clone()); - { - let gauge0 = gauge.get_or_create(&vec![("label".to_string(), "0".to_string())]); - gauge0.set(0); - } - - { - let gauge1 = gauge.get_or_create(&vec![("label".to_string(), "1".to_string())]); - gauge1.set(1); - } + gauge + .get_or_create(&vec![("label".to_string(), "0".to_string())]) + .set(0); + gauge + .get_or_create(&vec![("label".to_string(), "2".to_string())]) + .set(2); + gauge + .get_or_create(&vec![("label".to_string(), "1".to_string())]) + .set(1); let mut encoded = String::new(); encode(&mut encoded, ®istry).unwrap(); @@ -796,6 +796,7 @@ def parse(input): + "# TYPE my_gauge gauge\n" + "my_gauge{label=\"0\"} 0\n" + "my_gauge{label=\"1\"} 1\n" + + "my_gauge{label=\"2\"} 2\n" + "# EOF\n"; assert_eq!(expected, encoded); }