Skip to content

Commit

Permalink
test(logging): test if set_logger works
Browse files Browse the repository at this point in the history
  • Loading branch information
aljoshare committed Aug 26, 2024
1 parent f795b18 commit 78ef664
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ pub fn set_logger() -> Result<LevelFilter, CantAttachLogger> {

#[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)
}
}

0 comments on commit 78ef664

Please sign in to comment.