Fix cargo test

This commit is contained in:
Vinícius Miguel 2021-04-06 04:44:08 -03:00
parent f9272b5ce5
commit 5b70940596
2 changed files with 12 additions and 3 deletions

2
.gitignore vendored
View File

@ -2,6 +2,8 @@
# will have compiled files and executables
target/
makeshift_testing.py
# 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
Cargo.lock

View File

@ -86,23 +86,30 @@ mod argparsing {
}
#[test]
fn test_arg_parsing_decompress_subcommand() {
fn test_arg_parsing_decompress_subcommand() -> crate::Result<()> {
let files = vec!["a", "b", "c"];
make_dummy_files(&*files)?;
let files: Vec<_> = ["a", "b", "c"].iter().map(PathBuf::from).collect();
let expected = Command::Decompress {
files: files.clone(),
files: files.iter().filter_map(|p| fs::canonicalize(p).ok()).collect(),
output_folder: None,
};
assert_eq!(expected, parse!("a b c").command);
let expected = Command::Decompress {
files,
files: files.iter().map(fs::canonicalize).map(Result::unwrap).collect(),
output_folder: Some("folder".into()),
};
assert_eq!(expected, parse!("a b c --output folder").command);
assert_eq!(expected, parse!("a b --output folder c").command);
assert_eq!(expected, parse!("a --output folder b c").command);
assert_eq!(expected, parse!("--output folder a b c").command);
fs::remove_file("a")?;
fs::remove_file("b")?;
fs::remove_file("c")?;
Ok(())
}
}