Skip to content
Snippets Groups Projects
Verified Commit e95ded12 authored by Vincent Lafeychine's avatar Vincent Lafeychine
Browse files

tests(rrconfig): Add config read + write simple tests

parent 9c816f0b
No related branches found
No related tags found
1 merge request!49Replace deprecated methods in config
Pipeline #102442 passed
......@@ -259,3 +259,56 @@ pub fn set_no_verify(value: bool) {
pub fn check_overflows() -> bool {
read_setting("check_overflows")
}
#[cfg(test)]
mod tests {
use super::*;
// NOTE: These tests SHOULD NOT use the same key as the same SETTINGS variable is used
#[test]
fn read_default() {
assert_eq!(read_setting::<String>("work_dir"), ".");
}
#[test]
fn read_env() {
env::set_var("RR_simple_read", "true");
assert!(read_setting::<bool>("simple_read"));
}
#[test]
fn read_env_case() {
env::set_var("RR_CaSe_ChEcK", "true");
assert!(read_setting::<bool>("case_check"));
}
#[test]
fn read_env_value_bool() {
env::set_var("RR_CaSe_ChEcK", "1");
assert!(read_setting::<bool>("case_check"));
}
#[test]
fn write() {
write_setting("key", true);
assert!(read_setting::<bool>("key"));
write_setting("key", false);
assert!(!(read_setting::<bool>("key")));
}
#[test]
fn write_merge() {
write_setting("key1", "value1");
write_setting("key2", "value2");
assert_eq!(read_setting::<String>("key1"), "value1");
assert_eq!(read_setting::<String>("key2"), "value2");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment