summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2019-10-12 16:34:21 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-11-02 18:19:30 +0100
commit409660b07ba75e6773441a630f9c26eba9dea1da (patch)
tree3466fb2e6e0267547c46dbc945ba8b5d4d3901bb /tests
parent49af82cc68580568c0301dc14695988dd39c738e (diff)
Add test: check whether default configuration is added when imag-init is called
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/Cargo.toml13
-rw-r--r--tests/ui/src/imag_init.rs31
-rw-r--r--tests/ui/src/lib.rs1
3 files changed, 39 insertions, 6 deletions
diff --git a/tests/ui/Cargo.toml b/tests/ui/Cargo.toml
index d5595ca0..44f2d8d7 100644
--- a/tests/ui/Cargo.toml
+++ b/tests/ui/Cargo.toml
@@ -10,9 +10,10 @@ edition = "2018"
publish = false
[dependencies]
-assert_cmd = "0.11"
-assert_fs = "0.11"
-duct = "0.13"
-env_logger = "0.7"
-log = "0.4"
-predicates = "1"
+assert_cmd = "0.11"
+assert_fs = "0.11"
+duct = "0.13"
+env_logger = "0.7"
+log = "0.4"
+predicates = "1"
+pretty_assertions = "0.6"
diff --git a/tests/ui/src/imag_init.rs b/tests/ui/src/imag_init.rs
index 2c9cda31..0c3c6cab 100644
--- a/tests/ui/src/imag_init.rs
+++ b/tests/ui/src/imag_init.rs
@@ -48,3 +48,34 @@ fn test_init_makes_imag_dir() {
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);
+ });
+}
diff --git a/tests/ui/src/lib.rs b/tests/ui/src/lib.rs
index 3fffb1f8..827f8505 100644
--- a/tests/ui/src/lib.rs
+++ b/tests/ui/src/lib.rs
@@ -22,6 +22,7 @@ extern crate assert_fs;
extern crate env_logger;
extern crate predicates;
#[macro_use] extern crate log;
+#[macro_use] extern crate pretty_assertions;
#[cfg(test)] mod imag;
#[cfg(test)] mod imag_annotate;