aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-11-19 22:26:50 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-11-19 22:26:50 -0800
commit23a1fa44e8f69dedf23ea1e713a02b5112f9413a (patch)
tree654451bb1fd1311f41cdda5c38929c76501c44b9 /src/bin
parent6b7aed37b9671ddcb473ce411f18bbbc9186cc4d (diff)
downloadgeniza-23a1fa44e8f69dedf23ea1e713a02b5112f9413a.tar.gz
geniza-23a1fa44e8f69dedf23ea1e713a02b5112f9413a.zip
start testing CLI args
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/geniza-drive.rs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/bin/geniza-drive.rs b/src/bin/geniza-drive.rs
index 62bfc90..d402539 100644
--- a/src/bin/geniza-drive.rs
+++ b/src/bin/geniza-drive.rs
@@ -7,6 +7,9 @@ extern crate env_logger;
extern crate error_chain;
extern crate geniza;
+#[cfg(test)]
+extern crate assert_cli;
+
use geniza::*;
use std::path::Path;
use clap::{App, Arg, SubCommand};
@@ -182,3 +185,40 @@ fn run() -> Result<()> {
}
quick_main!(run);
+
+#[test]
+fn test_drive_cmd() {
+
+ assert_cli::Assert::cargo_binary("geniza-drive")
+ .with_args(&["-d", "/non-existant-dir", "ls"])
+ .fails();
+
+ assert_cli::Assert::cargo_binary("geniza-drive")
+ .with_args(&["-d", "test-data/dat/simple/.dat", "ls"])
+ .stdout().contains("README.md")
+ .succeeds();
+
+ assert_cli::Assert::cargo_binary("geniza-drive")
+ .with_args(&["-d", "test-data/dat/tree/.dat", "ls"])
+ .stdout().contains("Cantharellu")
+ .succeeds();
+
+ assert_cli::Assert::cargo_binary("geniza-drive")
+ .with_args(&["-d", "test-data/dat/alphabet/.dat", "cat", "/c"])
+ .stdout().is("c")
+ .succeeds();
+
+ assert_cli::Assert::cargo_binary("geniza-drive")
+ .with_args(&["-d", "test-data/dat/simple/.dat", "log"])
+ .stdout().contains("Felidae")
+ .succeeds();
+
+ assert_cli::Assert::cargo_binary("geniza-drive")
+ .with_args(&["-d", "test-data/dat/tree/.dat", "verify"])
+ .succeeds();
+
+ assert_cli::Assert::cargo_binary("geniza-drive")
+ .with_args(&["-d", "test-data/dat/tree/.dat", "dump-entries"])
+ .succeeds();
+
+}