From 23a1fa44e8f69dedf23ea1e713a02b5112f9413a Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Sun, 19 Nov 2017 22:26:50 -0800 Subject: start testing CLI args --- src/bin/geniza-drive.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/bin') 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(); + +} -- cgit v1.2.3