refactor: reorganize source and tests
This commit is contained in:
1 parent
15d76c18a0
commit
c6205a337c
139 files changed
+5532
-5548
No files matched your search
+2
-68
@@ -203,71 +203,5 @@ pub struct Config {
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn effective_java_path_none_when_absent() {
|
||||
let paths = Paths {
|
||||
java_path: None,
|
||||
..Paths::default()
|
||||
};
|
||||
assert!(paths.effective_java_path().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn effective_java_path_none_when_empty() {
|
||||
let paths = Paths {
|
||||
java_path: Some(String::new()),
|
||||
..Paths::default()
|
||||
};
|
||||
assert!(paths.effective_java_path().is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn effective_java_path_some_when_set() {
|
||||
let paths = Paths {
|
||||
java_path: Some("/usr/bin/java".to_owned()),
|
||||
..Paths::default()
|
||||
};
|
||||
assert_eq!(paths.effective_java_path(), Some("/usr/bin/java"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_path_absolute() {
|
||||
assert_eq!(resolve_path("/opt/rmcl"), PathBuf::from("/opt/rmcl"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_path_tilde_prefix() {
|
||||
let resolved = resolve_path("~/games/rmcl");
|
||||
assert!(!resolved.to_string_lossy().starts_with('~'));
|
||||
assert!(resolved.to_string_lossy().ends_with("games/rmcl"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_path_bare_tilde() {
|
||||
let resolved = resolve_path("~");
|
||||
assert!(!resolved.to_string_lossy().starts_with('~'));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_deserializes_from_empty_toml() {
|
||||
let config: Config = toml::from_str("").unwrap();
|
||||
assert_eq!(config.defaults.memory_max, "2G");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn config_deserializes_partial_toml() {
|
||||
let toml_str = r#"
|
||||
[general]
|
||||
debug = true
|
||||
|
||||
[defaults]
|
||||
memory_max = "8G"
|
||||
"#;
|
||||
let config: Config = toml::from_str(toml_str).unwrap();
|
||||
assert_eq!(config.defaults.memory_max, "8G");
|
||||
assert_eq!(config.defaults.memory_min, "512M");
|
||||
}
|
||||
}
|
||||
#[path = "tests/settings.rs"]
|
||||
mod tests;
|
||||
Reference in new issue
Block a user