diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2019-10-27 13:34:34 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2019-12-01 13:29:15 +0100 |
commit | f4719666538ed267557b58f4eb87c847bd1cacc0 (patch) | |
tree | db194f6c10e1662f3d86c6ecc20919d5f76d6f83 | |
parent | c2d4ec5fefe5de8871d974e7dd61af0fa618ae91 (diff) |
Add ui test for imag-view
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | tests/ui/src/imag_view.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/ui/src/imag_view.rs b/tests/ui/src/imag_view.rs index 987eadc5..e7bfe5e4 100644 --- a/tests/ui/src/imag_view.rs +++ b/tests/ui/src/imag_view.rs @@ -17,3 +17,42 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // +use std::process::Command; + +use assert_cmd::prelude::*; +use assert_fs::fixture::TempDir; +use predicates::prelude::*; + +/// Helper to call imag-init +pub fn call(tempdir: &TempDir, targets: &[&str]) -> Vec<String> { + let mut binary = binary(tempdir); + + // ensure that stdin is not used by the child process + binary.stdin(std::process::Stdio::inherit()); + + binary.arg("--ignore-ids"); + + for target in targets.iter() { + binary.arg(target); + } + + debug!("Command = {:?}", binary); + crate::imag::stdout_of_command(binary) +} + +pub fn binary(tempdir: &TempDir) -> Command { + crate::imag::binary(tempdir, "imag-view") +} + +#[test] +fn test_view_empty_entry_shows_nothing() { + crate::setup_logging(); + let imag_home = crate::imag::make_temphome(); + crate::imag_init::call(&imag_home); + crate::imag_create::call(&imag_home, &["test"]); + + let out = call(&imag_home, &["test"]); + debug!("out = '{:?}'", out); + assert!(out.iter().all(|s| s.is_empty())); +} + |