summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorToby Vincent <tobyv13@gmail.com>2022-11-20 13:35:45 -0600
committerToby Vincent <tobyv13@gmail.com>2022-11-20 13:35:45 -0600
commitb1438bd27d32e4e2530825026cc39a8ac5456f68 (patch)
tree5de916dc413e0f9c9c17d9e63828991e1a4a7af8 /src
parent4b182e71598c2eda5190b81708bafe6f9681999b (diff)
test: impl test for `logging::Config` and add `pretty_assertions`
Diffstat (limited to 'src')
-rw-r--r--src/config.rs1
-rw-r--r--src/finder.rs1
-rw-r--r--src/finder/config.rs1
-rw-r--r--src/logging/config.rs36
-rw-r--r--src/paths.rs1
-rw-r--r--src/paths/config.rs1
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() {