Skip to content

Commit

Permalink
Add a test to reproduce a bug
Browse files Browse the repository at this point in the history
Signed-off-by: ackintosh <sora.akatsuki@gmail.com>
  • Loading branch information
ackintosh committed Jan 6, 2023
1 parent 9141c11 commit e7c92dd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/encoding/protobuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,13 @@ mod tests {
])
.inc();

family
.get_or_create(&vec![
("method".to_string(), "POST".to_string()),
("status".to_string(), "200".to_string()),
])
.inc();

let metric_set = encode(&registry).unwrap();

let family = metric_set.metric_families.first().unwrap();
Expand All @@ -578,6 +585,7 @@ mod tests {
extract_metric_type(&metric_set)
);

// GET, 200
let metric = family.metrics.first().unwrap();
assert_eq!(2, metric.labels.len());
assert_eq!("method", metric.labels[0].name);
Expand All @@ -594,6 +602,14 @@ mod tests {
}
_ => panic!("wrong value type"),
}

// POST, 200
let metric = &family.metrics[1];
assert_eq!(2, metric.labels.len());
assert_eq!("method", metric.labels[0].name);
assert_eq!("POST", metric.labels[0].value);
assert_eq!("status", metric.labels[1].name);
assert_eq!("200", metric.labels[1].value);
}

#[test]
Expand Down

0 comments on commit e7c92dd

Please sign in to comment.