Skip to main content

Add a test for the --help command

ID
d9035c3
date
2024-08-20 00:04:18+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
b63d471
message
Add a test for the `--help` command
changed files
2 files, 12 additions, 1 deletion

Changed files

README.md (592) → README.md (580)

diff --git a/README.md b/README.md
index e047737..0783c93 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,6 @@ create-thumbnail PATH [--width=WIDTH | --height=HEIGHT] --out-dir=OUT_DIR
 focusing on a small piece of code makes it better
 
 * CLI:
-    -> help
     -> width + height
     -> neither of width/height
     -> width only

src/main.rs (3512) → src/main.rs (3806)

diff --git a/src/main.rs b/src/main.rs
index 3558120..01d72ac 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -113,6 +113,18 @@ mod test_cli {
         assert_eq!(output.stderr, "");
     }
 
+    #[test]
+    fn it_prints_the_help() {
+        let output = get_success(&["--help"]);
+
+        let re = Regex::new(r"create_thumbnail --out-dir").unwrap();
+
+        assert!(re.is_match(&output.stdout));
+
+        assert_eq!(output.exit_code, 0);
+        assert_eq!(output.stderr, "");
+    }
+
     struct DcOutput {
         exit_code: i32,
         stdout: String,