Every test in the workspace is a unit test inside the module it covers.
Nothing runs the diskern binary and checks what a user actually sees,
so the things only the binary does are unverified:
- argument parsing and the errors for bad input
- exit codes
- the grouping and ordering of printed findings
--json producing parseable JSON with the fields the README promises
The CLI's own tests cover human_bytes and nothing else. A regression in
print_findings — say every finding printed under the wrong verdict
heading — passes CI today.
assert_cmd plus tempfile is the usual
shape:
#[test]
fn scan_reports_a_temp_file_it_was_pointed_at() {
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("big.dmg"), vec![0u8; 4096]).unwrap();
Command::cargo_bin("diskern").unwrap()
.args(["scan", dir.path().to_str().unwrap()])
.assert()
.success()
.stdout(predicates::str::contains("Installers"));
}
Worth covering the --json path with serde_json::from_slice on stdout
rather than string matching, since that is the output other tools depend
on.
Keep fixtures inside a tempdir — scanning anything else from a test is
slow and machine-dependent.
crates/diskern-cli/src/main.rs:261
Every test in the workspace is a unit test inside the module it covers.
Nothing runs the
diskernbinary and checks what a user actually sees,so the things only the binary does are unverified:
--jsonproducing parseable JSON with the fields the README promisesThe CLI's own tests cover
human_bytesand nothing else. A regression inprint_findings— say every finding printed under the wrong verdictheading — passes CI today.
assert_cmdplustempfileis the usualshape:
Worth covering the
--jsonpath withserde_json::from_sliceon stdoutrather than string matching, since that is the output other tools depend
on.
Keep fixtures inside a
tempdir— scanning anything else from a test isslow and machine-dependent.
crates/diskern-cli/src/main.rs:261