Skip to content

Commit

Permalink
Merge pull request #14 from tofubert/first_test
Browse files Browse the repository at this point in the history
add first tests in config
tofubert authored Aug 28, 2024
2 parents e63e6f1 + 22d6e06 commit 6d11f32
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
@@ -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("");
}
}

0 comments on commit 6d11f32

Please sign in to comment.