diff --git a/crates/tor-config/src/path.rs b/crates/tor-config/src/path.rs index 187dbd2b5c0026caecbd06ceef4bb84996eeff6a..e641e58baeae0d935bd7a3aa9ed4705409bd634b 100644 --- a/crates/tor-config/src/path.rs +++ b/crates/tor-config/src/path.rs @@ -194,7 +194,6 @@ mod test { assert_eq!(p.path().unwrap().to_str(), Some("/usr/local/foo")); } - // FIXME: Add test for windows #[cfg(not(target_family = "windows"))] #[test] fn expand_home() { @@ -209,7 +208,20 @@ mod test { assert_eq!(p.path().unwrap().to_str(), expected.to_str()); } - // FIXME: Add test for windows + #[cfg(target_family = "windows")] + #[test] + fn expand_home() { + let p = CfgPath::new("~\\.arti\\config".to_string()); + assert_eq!(p.to_string(), "~\\.arti\\config".to_string()); + + let expected = dirs::home_dir().unwrap().join(".arti\\config"); + assert_eq!(p.path().unwrap().to_str(), expected.to_str()); + + let p = CfgPath::new("${USER_HOME}\\.arti\\config".to_string()); + assert_eq!(p.to_string(), "${USER_HOME}\\.arti\\config".to_string()); + assert_eq!(p.path().unwrap().to_str(), expected.to_str()); + } + #[cfg(not(target_family = "windows"))] #[test] fn expand_cache() { @@ -220,6 +232,16 @@ mod test { assert_eq!(p.path().unwrap().to_str(), expected.to_str()); } + #[cfg(target_family = "windows")] + #[test] + fn expand_cache() { + let p = CfgPath::new("${ARTI_CACHE}\\example".to_string()); + assert_eq!(p.to_string(), "${ARTI_CACHE}\\example".to_string()); + + let expected = project_dirs().unwrap().cache_dir().join("example"); + assert_eq!(p.path().unwrap().to_str(), expected.to_str()); + } + #[test] fn expand_bogus() { let p = CfgPath::new("${ARTI_WOMBAT}/example".to_string());