Skip to content

No end-to-end test runs the diskern binary #73

Description

@Muawiya-contact

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    clidiskern-cli: the terminal frontendgood first issueGood for newcomerslevel: intermediateNeeds familiarity with one cratepriority: mediumWorth doing, not urgenttestingTest coverage and test tooling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions