Fix path-related tests (#727)

This commit is contained in:
Denis Isidoro 2022-05-15 12:06:33 -03:00 committed by GitHub
parent 67d6a6a27f
commit 7e297fc2b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -281,16 +281,17 @@ mod tests {
let base_dirs = BaseDirs::new() let base_dirs = BaseDirs::new()
.ok_or(anyhow!("bad")) .ok_or(anyhow!("bad"))
.expect("could not determine base directories"); .expect("could not determine base directories");
let mut expect = base_dirs.config_dir().to_path_buf();
expect.push("navi"); let expected = {
expect.push("config.yaml"); let mut e = base_dirs.config_dir().to_path_buf();
let expect = match option_env!("NAVI_CONFIG") { e.push("navi");
Some(path) => path.to_string(), e.push("config.yaml");
None => expect.to_string_lossy().to_string(), e.to_string_lossy().to_string()
}; };
let config = default_config_pathbuf().expect("could not find default config path"); let config = default_config_pathbuf().expect("could not find default config path");
assert_eq!(expect, config.to_string_lossy().to_string()) assert_eq!(expected, config.to_string_lossy().to_string())
} }
#[test] #[test]
@ -298,15 +299,16 @@ mod tests {
let base_dirs = BaseDirs::new() let base_dirs = BaseDirs::new()
.ok_or(anyhow!("bad")) .ok_or(anyhow!("bad"))
.expect("could not determine base directories"); .expect("could not determine base directories");
let mut expect = base_dirs.data_dir().to_path_buf();
expect.push("navi"); let expected = {
expect.push("cheats"); let mut e = base_dirs.data_dir().to_path_buf();
let expect = match option_env!("NAVI_PATH") { e.push("navi");
Some(path) => path.to_string(), e.push("cheats");
None => expect.to_string_lossy().to_string(), e.to_string_lossy().to_string()
}; };
let cheats = default_cheat_pathbuf().expect("could not find default config path"); let cheats = default_cheat_pathbuf().expect("could not find default config path");
assert_eq!(expect, cheats.to_string_lossy().to_string()) assert_eq!(expected, cheats.to_string_lossy().to_string())
} }
} }