From 7ba980c5a9701215b182d82859f0f4c3255d38fa Mon Sep 17 00:00:00 2001 From: Jerboa-app Date: Mon, 13 May 2024 19:26:07 +0100 Subject: [PATCH] test errors --- src/config.rs | 6 +++--- tests/test_config.rs | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4714af6..dfdf4a6 100644 --- a/src/config.rs +++ b/src/config.rs @@ -94,7 +94,7 @@ pub fn read_config(path: &str) -> Option Some(d) => d, None => { - println!("Error reading configuration file {} no data", path); + crate::debug(format!("Error reading configuration file {} no data", path), None); return None } }; @@ -104,7 +104,7 @@ pub fn read_config(path: &str) -> Option Ok(data) => {data}, Err(why) => { - println!("Error reading configuration file {}\n{}", path, why); + crate::debug(format!("Error reading configuration file {}\n{}", path, why), None); return None } }; @@ -113,7 +113,7 @@ pub fn read_config(path: &str) -> Option } else { - println!("Error configuration file {} does not exist", path); + crate::debug(format!("Error configuration file {} does not exist", path), None); None } } \ No newline at end of file diff --git a/tests/test_config.rs b/tests/test_config.rs index faf1c95..9350ab8 100644 --- a/tests/test_config.rs +++ b/tests/test_config.rs @@ -40,4 +40,16 @@ mod config assert_eq!(config.content.server_cache_period_seconds, 1); assert_eq!(config.content.ignore_regexes.unwrap(), vec!["/.git", "workspace"]); } + + #[test] + fn test_config_error() + { + let missing_config = read_config("not_a_config"); + + assert!(missing_config.is_none()); + + let not_a_config = read_config("test/pages/b.html"); + + assert!(not_a_config.is_none()); + } } \ No newline at end of file