Fix the broken test for git-clean (#6055)

One of the tests for the build script had a hardcoded, windows-specific path. Now it is fixed, and a portable, temporary directory is used. Additionally, some missing asserts were added.
This commit is contained in:
Michał Wawrzyniec Urbańczyk 2023-03-27 17:20:27 +02:00 committed by GitHub
parent bf2545fa04
commit c669425ff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -123,9 +123,10 @@ mod tests {
#[tokio::test]
async fn test_cleaning() -> Result {
setup_logging()?;
let dir = PathBuf::from(r"C:\temp\test_cleaning");
crate::fs::tokio::reset_dir(&dir).await?;
Git.init(&dir).await?;
let dir = tempfile::tempdir()?;
let dir = dir.path();
crate::fs::tokio::reset_dir(dir).await?;
Git.init(dir).await?;
let foo = dir.join("foo");
let foo_target = foo.join("target");
@ -135,9 +136,9 @@ mod tests {
let target_foo = target.join("foo");
crate::fs::tokio::write(&target_foo, "foo in target").await?;
clean_except_for(&dir, vec!["target/foo"], false).await?;
clean_except_for(dir, vec!["target/foo"], false).await?;
assert!(!foo.exists());
assert!(target_foo.exists());
Ok(())
}