|
| 1 | +#[test] |
| 2 | +fn exe_invocation() { |
| 3 | + let actual = gix_path::env::exe_invocation(); |
| 4 | + assert!( |
| 5 | + !actual.as_os_str().is_empty(), |
| 6 | + "it finds something as long as git is installed somewhere on the system (or a default location)" |
| 7 | + ); |
| 8 | +} |
| 9 | + |
| 10 | +#[test] |
| 11 | +fn installation_config() { |
| 12 | + assert_ne!( |
| 13 | + gix_path::env::installation_config().map(|p| p.components().count()), |
| 14 | + gix_path::env::installation_config_prefix().map(|p| p.components().count()), |
| 15 | + "the prefix is a bit shorter than the installation config path itself" |
| 16 | + ); |
| 17 | +} |
| 18 | + |
| 19 | +#[test] |
| 20 | +fn system_prefix() { |
| 21 | + assert_ne!( |
| 22 | + gix_path::env::system_prefix(), |
| 23 | + None, |
| 24 | + "git should be present when running tests" |
| 25 | + ); |
| 26 | +} |
| 27 | + |
| 28 | +#[test] |
| 29 | +fn home_dir() { |
| 30 | + assert_ne!( |
| 31 | + gix_path::env::home_dir(), |
| 32 | + None, |
| 33 | + "we find a home on every system these tests execute" |
| 34 | + ); |
| 35 | +} |
| 36 | + |
| 37 | +mod xdg_config { |
| 38 | + use std::ffi::OsStr; |
| 39 | + |
| 40 | + #[test] |
| 41 | + fn prefers_xdg_config_bases() { |
| 42 | + let actual = gix_path::env::xdg_config("test", &mut |n| { |
| 43 | + (n == OsStr::new("XDG_CONFIG_HOME")).then(|| "marker".into()) |
| 44 | + }) |
| 45 | + .expect("set"); |
| 46 | + #[cfg(unix)] |
| 47 | + assert_eq!(actual.to_str(), Some("marker/git/test")); |
| 48 | + #[cfg(windows)] |
| 49 | + assert_eq!(actual.to_str(), Some("marker\\git\\test")); |
| 50 | + } |
| 51 | + |
| 52 | + #[test] |
| 53 | + fn falls_back_to_home() { |
| 54 | + let actual = gix_path::env::xdg_config("test", &mut |n| (n == OsStr::new("HOME")).then(|| "marker".into())) |
| 55 | + .expect("set"); |
| 56 | + #[cfg(unix)] |
| 57 | + assert_eq!(actual.to_str(), Some("marker/.config/git/test")); |
| 58 | + #[cfg(windows)] |
| 59 | + assert_eq!(actual.to_str(), Some("marker\\.config\\git\\test")); |
| 60 | + } |
| 61 | +} |
0 commit comments