From 78ef664ff8620914225729e97c841eb7ff0df9fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aljoscha=20P=C3=B6rtner?= Date: Mon, 26 Aug 2024 20:54:59 +0200 Subject: [PATCH] test(logging): test if set_logger works --- src/logging.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/logging.rs b/src/logging.rs index d429f8e..0ad16a2 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -21,10 +21,17 @@ pub fn set_logger() -> Result { #[cfg(test)] mod tests { + use std::env; + use crate::logging::set_logger; + use rstest::*; - #[test] - fn is_logger_set() { - assert!(set_logger()); + #[rstest] + #[case("info")] + fn set_valid_logger(#[case] log_level: String) { + env::set_var("RUST_LOG", &log_level); + let result = set_logger(); + assert!(result.is_ok()); + assert_eq!(result.unwrap().to_string(), log_level) } }