Merge branch 'ui-testing-imag-view' into master

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-12-01 15:01:52 +01:00
commit b272c1508c

View file

@ -17,3 +17,42 @@
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // 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()));
}