diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/config.rs | 1 | ||||
-rw-r--r-- | src/finder.rs | 1 | ||||
-rw-r--r-- | src/finder/config.rs | 1 | ||||
-rw-r--r-- | src/logging/config.rs | 36 | ||||
-rw-r--r-- | src/paths.rs | 1 | ||||
-rw-r--r-- | src/paths/config.rs | 1 |
6 files changed, 41 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index 00aa1dc..5946102 100644 --- a/src/config.rs +++ b/src/config.rs @@ -45,6 +45,7 @@ impl TryFrom<Figment> for Config { mod tests { use super::*; use figment::providers::{Format, Serialized, Toml}; + use pretty_assertions::assert_eq; #[test] fn test_extract() { diff --git a/src/finder.rs b/src/finder.rs index c5b5bd5..ad7e303 100644 --- a/src/finder.rs +++ b/src/finder.rs @@ -80,6 +80,7 @@ impl DerefMut for FinderChild { #[cfg(test)] mod tests { use super::*; + use pretty_assertions::assert_eq; #[test] fn test_output() { diff --git a/src/finder/config.rs b/src/finder/config.rs index 4ef2b43..4c3abda 100644 --- a/src/finder/config.rs +++ b/src/finder/config.rs @@ -53,6 +53,7 @@ impl Provider for Config { mod tests { use super::*; use figment::providers::{Format, Serialized, Toml}; + use pretty_assertions::assert_eq; #[test] fn test_extract() { diff --git a/src/logging/config.rs b/src/logging/config.rs index 2f7be0f..1663f13 100644 --- a/src/logging/config.rs +++ b/src/logging/config.rs @@ -47,3 +47,39 @@ impl Default for Config { } } } + +#[cfg(test)] +mod tests { + use super::*; + use figment::providers::{Format, Serialized, Toml}; + use pretty_assertions::assert_eq; + + #[test] + fn test_extract() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "tmuxr.toml", + r#" + stdout = "warn" + level = "info" + path = "/path/to/logfile.log" + "#, + )?; + + let config: Config = Figment::from(Serialized::defaults(Config::default())) + .merge(Toml::file("tmuxr.toml")) + .extract()?; + + assert_eq!( + config, + Config { + stdout: Some(Level::WARN), + level: Some(Level::INFO), + path: "/path/to/logfile.log".into() + } + ); + + Ok(()) + }); + } +} diff --git a/src/paths.rs b/src/paths.rs index d9c1214..9b9963a 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -69,6 +69,7 @@ impl Iterator for Paths { #[cfg(test)] mod tests { use super::*; + use pretty_assertions::assert_eq; use std::fs; #[test] diff --git a/src/paths/config.rs b/src/paths/config.rs index 4756d02..e5af2dc 100644 --- a/src/paths/config.rs +++ b/src/paths/config.rs @@ -90,6 +90,7 @@ impl<'de> Deserialize<'de> for PathEntry { mod tests { use super::*; use figment::providers::{Format, Serialized, Toml}; + use pretty_assertions::assert_eq; #[test] fn test_extract() { |