Move some tests to lib.rs
This commit is contained in:
parent
de45ffc15c
commit
3c960eaa35
26
src/lib.rs
26
src/lib.rs
@ -68,3 +68,29 @@ pub fn init() -> std::result::Result<(), log::SetLoggerError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn write_settings() {
|
||||||
|
let s = settings::Settings::new();
|
||||||
|
let path = std::path::Path::new("test.yaml");
|
||||||
|
let settings = r#"---
|
||||||
|
version: "1"
|
||||||
|
categories: {}
|
||||||
|
rules: []"#;
|
||||||
|
utils::write_file(&path, &serde_yaml::to_string(&s).unwrap()).unwrap();
|
||||||
|
assert_eq!(settings, utils::read_file(&path).unwrap());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn read_settings() {
|
||||||
|
let s1 = settings::Settings::new();
|
||||||
|
let path = std::path::Path::new("test.yml");
|
||||||
|
s1.export(&path).unwrap();
|
||||||
|
let s2 = settings::Settings::import(&path).unwrap();
|
||||||
|
assert_eq!(s1, s2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -403,24 +403,3 @@ impl PartialEq for Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for Settings {}
|
impl Eq for Settings {}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn write_settings() {
|
|
||||||
let s = Settings::new();
|
|
||||||
let path = std::path::Path::new("test.yaml");
|
|
||||||
let settings = r#"---
|
|
||||||
version: "1"
|
|
||||||
categories: {}
|
|
||||||
rules: []"#;
|
|
||||||
utils::write_file(&path, &serde_yaml::to_string(&s).unwrap()).unwrap();
|
|
||||||
assert_eq!(settings, utils::read_file(&path).unwrap());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn read_settings() {
|
|
||||||
let s1 = Settings::new();
|
|
||||||
let path = std::path::Path::new("test.yml");
|
|
||||||
s1.export(&path).unwrap();
|
|
||||||
let s2 = Settings::import(&path).unwrap();
|
|
||||||
assert_eq!(s1, s2);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user