Skip to content

Commit ea41408

Browse files
lstrojnyspoutn1k
authored andcommitted
Let’s not lie in the test
Signed-off-by: Lars Strojny <[email protected]>
1 parent fab0ac4 commit ea41408

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/encoding/text.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ def parse(input):
12451245
}
12461246

12471247
#[test]
1248-
fn metrics_are_sorted_by_registration_order() {
1248+
fn metrics_are_sorted_in_registration_order() {
12491249
let mut registry = Registry::default();
12501250
let counter: Counter = Counter::default();
12511251
let another_counter: Counter = Counter::default();
@@ -1266,20 +1266,20 @@ def parse(input):
12661266
}
12671267

12681268
#[test]
1269-
fn metric_family_is_sorted_by_registration_order() {
1269+
fn metric_family_is_sorted_lexicographically() {
12701270
let mut registry = Registry::default();
12711271
let gauge = Family::<Vec<(String, String)>, Gauge>::default();
12721272
registry.register("my_gauge", "My gauge", gauge.clone());
12731273

1274-
{
1275-
let gauge0 = gauge.get_or_create(&vec![("label".to_string(), "0".to_string())]);
1276-
gauge0.set(0);
1277-
}
1278-
1279-
{
1280-
let gauge1 = gauge.get_or_create(&vec![("label".to_string(), "1".to_string())]);
1281-
gauge1.set(1);
1282-
}
1274+
gauge
1275+
.get_or_create(&vec![("label".to_string(), "0".to_string())])
1276+
.set(0);
1277+
gauge
1278+
.get_or_create(&vec![("label".to_string(), "2".to_string())])
1279+
.set(2);
1280+
gauge
1281+
.get_or_create(&vec![("label".to_string(), "1".to_string())])
1282+
.set(1);
12831283

12841284
let mut encoded = String::new();
12851285
encode(&mut encoded, &registry).unwrap();
@@ -1288,6 +1288,7 @@ def parse(input):
12881288
+ "# TYPE my_gauge gauge\n"
12891289
+ "my_gauge{label=\"0\"} 0\n"
12901290
+ "my_gauge{label=\"1\"} 1\n"
1291+
+ "my_gauge{label=\"2\"} 2\n"
12911292
+ "# EOF\n";
12921293
assert_eq!(expected, encoded);
12931294
}

0 commit comments

Comments
 (0)