mirror of
https://git.proxmox.com/git/pmg-log-tracker
synced 2025-08-04 16:50:05 +00:00

Add tests for some command line options. Not all have a test yet, but at least most of the ones used by the GUI (-s, -e, -q, -x). '-g' and '-n' are currently still missing. The tests will only be valid until end of January 31st 2021 because of missing year info in the syslog. Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com> Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
32 lines
1020 B
Rust
32 lines
1020 B
Rust
use std::io::BufRead;
|
|
|
|
pub fn compare_output<R: BufRead, R2: BufRead>(command: R, expected: R2) {
|
|
let expected_lines: Vec<String> = expected.lines().map(|l| l.unwrap()).collect();
|
|
let command_lines: Vec<String> = command.lines().map(|l| l.unwrap()).collect();
|
|
assert_eq!(
|
|
expected_lines.len(),
|
|
command_lines.len(),
|
|
"expected: {}, command: {}",
|
|
expected_lines.len(),
|
|
command_lines.len()
|
|
);
|
|
for (old, new) in expected_lines.iter().zip(command_lines.iter())
|
|
{
|
|
if new.starts_with("# ") && old.starts_with("# ") {
|
|
continue;
|
|
} else if new.starts_with("# ") {
|
|
assert!(
|
|
false,
|
|
"comment line found in command output, but not in expected output"
|
|
);
|
|
} else if old.starts_with("# ") {
|
|
assert!(
|
|
false,
|
|
"comment line found in expected output, but not in command output"
|
|
);
|
|
}
|
|
|
|
assert_eq!(new, old);
|
|
}
|
|
}
|