Add test: check whether default configuration is added when imag-init is called
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
49af82cc68
commit
409660b07b
3 changed files with 39 additions and 6 deletions
|
@ -16,3 +16,4 @@ duct = "0.13"
|
||||||
env_logger = "0.7"
|
env_logger = "0.7"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
predicates = "1"
|
predicates = "1"
|
||||||
|
pretty_assertions = "0.6"
|
||||||
|
|
|
@ -48,3 +48,34 @@ fn test_init_makes_imag_dir() {
|
||||||
assert!(imag_home.path().exists(), "imag dir does not exist");
|
assert!(imag_home.path().exists(), "imag dir does not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_init_creates_default_config() {
|
||||||
|
use pretty_assertions::assert_eq;
|
||||||
|
|
||||||
|
crate::setup_logging();
|
||||||
|
let imag_home = crate::imag::make_temphome();
|
||||||
|
call(&imag_home);
|
||||||
|
|
||||||
|
const CONFIGURATION_STR : &str = include_str!("../../../imagrc.toml");
|
||||||
|
let config = std::fs::read_to_string({
|
||||||
|
let mut path = imag_home.path().to_path_buf();
|
||||||
|
path.push("imagrc.toml");
|
||||||
|
path
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// the imagrc is based on the example imagrc from this repository, but the one
|
||||||
|
// thing that differs is that the default level for logging output is "info" rather than
|
||||||
|
// "default"
|
||||||
|
CONFIGURATION_STR
|
||||||
|
.to_string()
|
||||||
|
.replace(
|
||||||
|
r#"level = "debug""#,
|
||||||
|
r#"level = "info""#
|
||||||
|
)
|
||||||
|
.lines()
|
||||||
|
.zip(config.lines())
|
||||||
|
.for_each(|(orig, created)| {
|
||||||
|
assert_eq!(orig, created);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ extern crate assert_fs;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate predicates;
|
extern crate predicates;
|
||||||
#[macro_use] extern crate log;
|
#[macro_use] extern crate log;
|
||||||
|
#[macro_use] extern crate pretty_assertions;
|
||||||
|
|
||||||
#[cfg(test)] mod imag;
|
#[cfg(test)] mod imag;
|
||||||
#[cfg(test)] mod imag_annotate;
|
#[cfg(test)] mod imag_annotate;
|
||||||
|
|
Loading…
Reference in a new issue