Partial implementation of Tasks and Logs and test refactor
This commit is contained in:
+4
-29
@@ -4,6 +4,10 @@ use log4rs::config::{Appender, Root};
|
||||
use log4rs::encode::pattern::PatternEncoder;
|
||||
use regex::Regex;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "utils_tests.rs"]
|
||||
mod utils_tests;
|
||||
|
||||
pub fn init_logging_config() -> log4rs::Config {
|
||||
let file_path = "/tmp/managarr.log";
|
||||
let logfile = FileAppender::builder()
|
||||
@@ -40,32 +44,3 @@ pub fn strip_non_search_characters(input: &str) -> String {
|
||||
.replace_all(&input.to_lowercase(), "")
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::utils::{convert_runtime, convert_to_gb, strip_non_search_characters};
|
||||
|
||||
#[test]
|
||||
fn test_convert_to_gb() {
|
||||
assert_eq!(convert_to_gb(2147483648), 2f64);
|
||||
assert_eq!(convert_to_gb(2662879723), 2.4799999995157123);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_convert_runtime() {
|
||||
let (hours, minutes) = convert_runtime(154);
|
||||
|
||||
assert_eq!(hours, 2);
|
||||
assert_eq!(minutes, 34);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_strip_non_alphanumeric_characters() {
|
||||
assert_eq!(
|
||||
strip_non_search_characters("Te$t S7r!ng::'~-@_`,(.)/*}^&%#+="),
|
||||
"tet s7rng::'-,./".to_owned()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user