Skip to content

Commit 22d6e06

Browse files
committed
add first tests in config
1 parent e63e6f1 commit 22d6e06

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/config/mod.rs

+28
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,31 @@ impl Config {
195195
log4rs::init_config(config).expect("Failed to init logging");
196196
}
197197
}
198+
199+
#[cfg(test)]
200+
mod tests {
201+
// use super::*;
202+
203+
#[test]
204+
#[should_panic(expected = "config not initialized")]
205+
fn get_config_before_init() {
206+
super::get();
207+
}
208+
#[test]
209+
#[should_panic(
210+
expected = "Could not Create Config dir: Os { code: 13, kind: PermissionDenied, message: \"Permission denied\" }"
211+
)]
212+
fn init_with_faulty_path() {
213+
super::init("/test");
214+
}
215+
#[test]
216+
fn init_with_no_path() {
217+
super::init("");
218+
}
219+
#[test]
220+
#[should_panic(expected = "Could not set global config!: failed to set config Config")]
221+
fn init_config_twice() {
222+
super::init("");
223+
super::init("");
224+
}
225+
}

0 commit comments

Comments
 (0)