diff options
author | Toby Vincent <tobyv13@gmail.com> | 2022-11-20 13:35:45 -0600 |
---|---|---|
committer | Toby Vincent <tobyv13@gmail.com> | 2022-11-20 13:35:45 -0600 |
commit | b1438bd27d32e4e2530825026cc39a8ac5456f68 (patch) | |
tree | 5de916dc413e0f9c9c17d9e63828991e1a4a7af8 /src/logging | |
parent | 4b182e71598c2eda5190b81708bafe6f9681999b (diff) |
test: impl test for `logging::Config` and add `pretty_assertions`
Diffstat (limited to 'src/logging')
-rw-r--r-- | src/logging/config.rs | 36 |
1 files changed, 36 insertions, 0 deletions
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(()) + }); + } +} |