Add a test for thumbnailing a non-image format
- ID
a8b0a43- date
2024-08-20 12:00:38+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
f2f83dc- message
Add a test for thumbnailing a non-image format- changed files
1 file, 16 additions, 2 deletions
Changed files
src/main.rs (5283) → src/main.rs (5699)
diff --git a/src/main.rs b/src/main.rs
index 7239b29..138bc2c 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -45,8 +45,13 @@ fn main() {
_ => unreachable!(),
};
- let thumbnail_path = create_thumbnail(&cli.path, &cli.out_dir, target).unwrap();
- print!("{}", thumbnail_path.display());
+ match create_thumbnail(&cli.path, &cli.out_dir, target) {
+ Ok(thumbnail_path) => print!("{}", thumbnail_path.display()),
+ Err(e) => {
+ eprintln!("{}", e);
+ std::process::exit(1);
+ }
+ };
}
#[cfg(test)]
@@ -107,6 +112,15 @@ mod test_cli {
}
#[test]
+ fn it_errors_if_you_pass_a_non_image() {
+ let output = get_failure(&["Cargo.toml", "--width=50", "--out-dir=/tmp"]);
+
+ assert_eq!(output.exit_code, 1);
+ assert_eq!(output.stderr, "The image format could not be determined\n");
+ assert_eq!(output.stdout, "");
+ }
+
+ #[test]
fn it_prints_the_version() {
let output = get_success(&["--version"]);