Fix relative path tests

They'd fail when the current working directory was on a different drive
to the default temporary directory.
This commit is contained in:
Oliver Hamlet
2025-03-26 21:44:41 +00:00
parent 7d2324816a
commit 6538a91468
2 changed files with 16 additions and 2 deletions
+2 -2
View File
@@ -904,7 +904,7 @@ mod tests {
#[test]
fn should_succeed_if_given_a_relative_game_path() {
let fixture = Fixture::new(GameType::TES3);
let fixture = Fixture::in_path(GameType::TES3, Path::new("target"));
let game_path = make_relative(&fixture.game_path);
assert!(game_path.is_relative());
@@ -972,7 +972,7 @@ mod tests {
#[test]
fn should_succeed_if_given_relative_paths() {
let fixture = Fixture::new(GameType::TES4);
let fixture = Fixture::in_path(GameType::TES3, Path::new("target"));
let game_path = make_relative(&fixture.game_path);
assert!(game_path.is_relative());
+14
View File
@@ -179,6 +179,20 @@ impl Fixture {
.prefix("libloot-t\u{00E9}st-")
.tempdir()
.unwrap();
Self::with_tempdir(game_type, temp_dir)
}
pub fn in_path(game_type: GameType, in_path: &Path) -> Fixture {
let temp_dir = tempfile::Builder::new()
.prefix("libloot-t\u{00E9}st-")
.tempdir_in(in_path)
.unwrap();
Self::with_tempdir(game_type, temp_dir)
}
fn with_tempdir(game_type: GameType, temp_dir: TempDir) -> Fixture {
let root_path = temp_dir.path();
let game_path = root_path.join("games/game");
let local_path = root_path.join("local/game");