Skip to content

Commit

Permalink
tests: test migration with fake files
Browse files Browse the repository at this point in the history
  • Loading branch information
mistydemeo committed Apr 17, 2024
1 parent 918005c commit 6c7a842
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions cargo-dist/tests/gallery/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,23 @@ impl DistResult {
}
std::fs::create_dir_all(&tempdir).unwrap();

let expected_bin_dir = Utf8PathBuf::from(expected_bin_dir);
let bin_dir = tempdir.join(&expected_bin_dir);
// Test generating fake old binaries within the older
// flat directory structure, allowing us to simulate
// performing a migration
if !expected_bin_dir
.components()
.any(|d| d.as_str() == ".cargo")
{
let root = bin_dir.parent().unwrap();
std::fs::create_dir_all(&root).unwrap;

Check failure on line 692 in cargo-dist/tests/gallery/dist.rs

View workflow job for this annotation

GitHub Actions / clippy

attempted to take value of method `unwrap` on type `std::result::Result<(), std::io::Error>`

error[E0615]: attempted to take value of method `unwrap` on type `std::result::Result<(), std::io::Error>` --> cargo-dist/tests/gallery/dist.rs:692:48 | 692 | std::fs::create_dir_all(&root).unwrap; | ^^^^^^ method, not a field | help: use parentheses to call the method | 692 | std::fs::create_dir_all(&root).unwrap(); | ++

Check failure on line 692 in cargo-dist/tests/gallery/dist.rs

View workflow job for this annotation

GitHub Actions / clippy

attempted to take value of method `unwrap` on type `std::result::Result<(), std::io::Error>`

error[E0615]: attempted to take value of method `unwrap` on type `std::result::Result<(), std::io::Error>` --> cargo-dist/tests/gallery/dist.rs:692:48 | 692 | std::fs::create_dir_all(&root).unwrap; | ^^^^^^ method, not a field | help: use parentheses to call the method | 692 | std::fs::create_dir_all(&root).unwrap(); | ++
for bin_name in ctx.repo.bins {
let old_path = root.join(bin_name);
std::fs::File::create(old_path).unwrap();
}
}

// Run the installer script with:
//
// HOME="{tempdir}" (for install-path=~/... and install-path=CARGO_HOME)
Expand All @@ -700,8 +717,6 @@ impl DistResult {
tempdir.join(".zshrc"),
];
let receipt_file = tempdir.join(format!(".config/{app_name}/{app_name}-receipt.json"));
let expected_bin_dir = Utf8PathBuf::from(expected_bin_dir);
let bin_dir = tempdir.join(expected_bin_dir);
let env_dir = bin_dir.parent().unwrap();
let env_script = env_dir.join("env");

Expand Down

0 comments on commit 6c7a842

Please sign in to comment.