Add test: Check whether imag-header prints correct string when querying imag.version header

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-10-13 13:00:07 +02:00
parent 4b3e2ea4cd
commit 4cbcdc118c
2 changed files with 23 additions and 0 deletions

View file

@ -18,3 +18,5 @@ log = "0.4"
predicates = "1" predicates = "1"
pretty_assertions = "0.6" pretty_assertions = "0.6"
semver = "0.9" semver = "0.9"
version = "3"

View file

@ -21,6 +21,7 @@ use std::process::Command;
use assert_cmd::prelude::*; use assert_cmd::prelude::*;
use assert_fs::fixture::TempDir; use assert_fs::fixture::TempDir;
use predicates::prelude::*;
pub fn binary(tempdir: &TempDir) -> Command { pub fn binary(tempdir: &TempDir) -> Command {
crate::imag::binary(tempdir, "imag-header") crate::imag::binary(tempdir, "imag-header")
@ -40,3 +41,23 @@ fn test_no_header_besides_version_after_creation() {
bin.assert().success(); bin.assert().success();
} }
#[test]
fn test_imag_version_as_semver_string() {
crate::setup_logging();
let imag_home = crate::imag::make_temphome();
crate::imag_init::call(&imag_home);
crate::imag_create::call(&imag_home, &["test"]);
let imag_version = version::version!();
let mut bin = binary(&imag_home);
bin.arg("test");
bin.arg("string");
bin.arg("imag.version");
let expected_output_str = format!("test - {}", imag_version);
bin.assert()
.stdout(predicate::eq(expected_output_str.as_bytes()))
.success();
}