From 22d6e06f68218c86c364cbdac0b77886b26fcc55 Mon Sep 17 00:00:00 2001 From: Michel von Czettritz und Neuhaus Date: Wed, 28 Aug 2024 09:39:16 +0200 Subject: [PATCH] add first tests in config --- src/config/mod.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/config/mod.rs b/src/config/mod.rs index 2fd65b5..8945397 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -195,3 +195,31 @@ impl Config { log4rs::init_config(config).expect("Failed to init logging"); } } + +#[cfg(test)] +mod tests { + // use super::*; + + #[test] + #[should_panic(expected = "config not initialized")] + fn get_config_before_init() { + super::get(); + } + #[test] + #[should_panic( + expected = "Could not Create Config dir: Os { code: 13, kind: PermissionDenied, message: \"Permission denied\" }" + )] + fn init_with_faulty_path() { + super::init("/test"); + } + #[test] + fn init_with_no_path() { + super::init(""); + } + #[test] + #[should_panic(expected = "Could not set global config!: failed to set config Config")] + fn init_config_twice() { + super::init(""); + super::init(""); + } +}