Skip to content

Commit d2519eb

Browse files
committed
Use test_case macro instead of regular test
1 parent 18140aa commit d2519eb

File tree

4 files changed

+43
-8
lines changed

4 files changed

+43
-8
lines changed

Cargo.lock

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ serde_json = "1"
3535
serde_yaml = "0.9"
3636
serial_test = "3.2"
3737
sysinfo = "0.29"
38+
test-case = "3.3"
3839
thiserror = "2"
3940
tokio = "1"
4041
tower = "0.5"

lustre-collector/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ tracing-subscriber.workspace = true
1919
[dev-dependencies]
2020
include_dir.workspace = true
2121
insta.workspace = true
22+
test-case.workspace = true
2223
tokio = { workspace = true, features = ["full"] }
2324
criterion = { workspace = true, features = ["html_reports", "async_tokio"] }
2425
sysinfo.workspace = true

lustre-collector/src/recovery_status_parser.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ mod tests {
241241
use crate::parser::parse;
242242
use crate::recovery_status_parser::{clients_line, target_recovery_stats};
243243
use combine::{Parser, parser::EasyParser, stream::position};
244+
use test_case::test_case;
244245

245246
#[test]
246247
fn test_multiple() {
@@ -276,14 +277,12 @@ mod tests {
276277
insta::assert_debug_snapshot!(records);
277278
}
278279

279-
#[test]
280-
fn test_clients_line() {
281-
let result = clients_line("completed_clients").parse("completed_clients: 3/7\n");
282-
assert_eq!(result, Ok(((3, Some(7)), "")));
283-
let result = clients_line("connected_clients").parse("connected_clients: 3/7\n");
284-
assert_eq!(result, Ok(((3, Some(7)), "")));
285-
let result = clients_line("completed_clients").parse("completed_clients: 3\n");
286-
assert_eq!(result, Ok(((3, None), "")));
280+
#[test_case("completed_clients", "completed_clients: 3/7\n", (3, Some(7)); "completed clients with total")]
281+
#[test_case("connected_clients", "connected_clients: 3/7\n", (3, Some(7)); "connected clients with total")]
282+
#[test_case("completed_clients", "completed_clients: 3\n", (3, None); "completed clients without total")]
283+
fn test_clients_line(field_name: &'static str, input: &str, expected: (u64, Option<u64>)) {
284+
let result = clients_line(field_name).parse(input);
285+
assert_eq!(result, Ok((expected, "")));
287286
}
288287

289288
#[test]

0 commit comments

Comments
 (0)