From f4719666538ed267557b58f4eb87c847bd1cacc0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 27 Oct 2019 13:34:34 +0100 Subject: [PATCH] Add ui test for imag-view Signed-off-by: Matthias Beyer --- tests/ui/src/imag_view.rs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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 { + 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())); +} +