Skip to content

Commit 5bdc9f3

Browse files
committed
Let’s not lie in the test
Signed-off-by: Lars Strojny <[email protected]>
1 parent bccf17f commit 5bdc9f3

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/encoding/text.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ def parse(input):
753753
}
754754

755755
#[test]
756-
fn metrics_are_sorted_by_registration_order() {
756+
fn metrics_are_sorted_in_registration_order() {
757757
let mut registry = Registry::default();
758758
let counter: Counter = Counter::default();
759759
let another_counter: Counter = Counter::default();
@@ -774,20 +774,20 @@ def parse(input):
774774
}
775775

776776
#[test]
777-
fn metric_family_is_sorted_by_registration_order() {
777+
fn metric_family_is_sorted_lexicographically() {
778778
let mut registry = Registry::default();
779779
let gauge = Family::<Vec<(String, String)>, Gauge>::default();
780780
registry.register("my_gauge", "My gauge", gauge.clone());
781781

782-
{
783-
let gauge0 = gauge.get_or_create(&vec![("label".to_string(), "0".to_string())]);
784-
gauge0.set(0);
785-
}
786-
787-
{
788-
let gauge1 = gauge.get_or_create(&vec![("label".to_string(), "1".to_string())]);
789-
gauge1.set(1);
790-
}
782+
gauge
783+
.get_or_create(&vec![("label".to_string(), "0".to_string())])
784+
.set(0);
785+
gauge
786+
.get_or_create(&vec![("label".to_string(), "2".to_string())])
787+
.set(2);
788+
gauge
789+
.get_or_create(&vec![("label".to_string(), "1".to_string())])
790+
.set(1);
791791

792792
let mut encoded = String::new();
793793
encode(&mut encoded, &registry).unwrap();
@@ -796,6 +796,7 @@ def parse(input):
796796
+ "# TYPE my_gauge gauge\n"
797797
+ "my_gauge{label=\"0\"} 0\n"
798798
+ "my_gauge{label=\"1\"} 1\n"
799+
+ "my_gauge{label=\"2\"} 2\n"
799800
+ "# EOF\n";
800801
assert_eq!(expected, encoded);
801802
}

0 commit comments

Comments
 (0)