Skip to content

Commit

Permalink
chore: directly call content_normalize
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored and jyn514 committed Dec 18, 2022
1 parent b6a6f5d commit 75414ca
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ Temporary Items
# Generated by Cargo
# will have compiled files and executables
/target/
/tests/sample-project/target/
/tests/fresh-prefix/.hidden/hidden-project/target

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand Down
12 changes: 4 additions & 8 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,7 @@ fn error_status() -> TestResult {
Ok(())
}

fn golden_reference(
args: &[&str],
file: &str,
content_modifier: fn(content: &mut String),
) -> TestResult {
fn golden_reference(args: &[&str], file: &str) -> TestResult {
let mut cmd = Command::new(cargo_bin("cargo-sweep"));
let mut assert = run(cmd.args(args));

Expand All @@ -257,7 +253,7 @@ fn golden_reference(
fs::write(file, actual)?;
} else {
let mut expected = fs::read_to_string(file).context("failed to read usage file")?;
content_modifier(&mut expected);
content_normalize(&mut expected);
assert_eq!(actual, expected);
}
Ok(())
Expand Down Expand Up @@ -288,10 +284,10 @@ fn content_normalize(content: &mut String) {

#[test]
fn subcommand_usage() -> TestResult {
golden_reference(&["sweep", "-h"], "tests/usage.txt", content_normalize)
golden_reference(&["sweep", "-h"], "tests/usage.txt")
}

#[test]
fn standalone_usage() -> TestResult {
golden_reference(&["-h"], "tests/standalone-usage.txt", content_normalize)
golden_reference(&["-h"], "tests/standalone-usage.txt")
}

0 comments on commit 75414ca

Please sign in to comment.