artifactize-core 0.27.0

The library behind artifactize: Artifacts, evals, reviews, the monitor and review models, and the shared operations every interface calls.
Documentation
use super::*;

#[test]
fn transient_file_access_is_only_error_access_denied() {
    assert!(transient_file_access(&io::Error::from_raw_os_error(
        ERROR_ACCESS_DENIED as i32
    )));
    for other in [
        2,  /* ERROR_FILE_NOT_FOUND */
        32, /* ERROR_SHARING_VIOLATION */
    ] {
        assert!(!transient_file_access(&io::Error::from_raw_os_error(other)));
    }
    assert!(!transient_file_access(&io::Error::new(
        io::ErrorKind::PermissionDenied,
        "no raw code"
    )));
}

// Only Windows has delete-sharing modes; Unix open handles do not block unlinking.
#[test]
fn delete_sharing_observation_never_removes_the_owned_file() {
    let root = crate::test_os::tempdir();
    let path = root.path().join("held-file");
    std::fs::write(&path, "owned content").unwrap();
    let holder = crate::test_os::hold_without_delete_sharing(&path);
    crate::test_os::assert_delete_blocked(&path);
    assert_eq!(std::fs::read_to_string(&path).unwrap(), "owned content");
    drop(holder);
    // A regressed fixture must fail the assertion without destroying its evidence.
    assert!(std::panic::catch_unwind(|| crate::test_os::assert_delete_blocked(&path)).is_err());
    assert_eq!(std::fs::read_to_string(&path).unwrap(), "owned content");
}