dir-diff icon indicating copy to clipboard operation
dir-diff copied to clipboard

Library doesn't work if one directory is empty and the second is not

Open AJIOB opened this issue 1 year ago • 0 comments

Code:

#[tokio::test]
async fn only_one_empty_dir() {
    let temp_dir1 = Temp::new_dir().expect("Failed to create temp dir 1");
    let temp_dir2 = Temp::new_dir().expect("Failed to create temp dir 2");

    let temp_file1 = temp_dir1.join("file1");
    fs::write(temp_file1, "")
        .await
        .expect("Failed to write to temp file 1");

    assert!(
        dir_diff::is_different(temp_dir1, temp_dir2).expect("Failed to compare dirs"),
        "One dir has empty file and other not"
    );
}

Test dependencies:

  • tokio with fs & macro features (for file creation asynchronously & async test run) - std::fs may be used for this
  • mktemp for temp dirs creation

AJIOB avatar Feb 09 '24 07:02 AJIOB