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,
32,
] {
assert!(!transient_file_access(&io::Error::from_raw_os_error(other)));
}
assert!(!transient_file_access(&io::Error::new(
io::ErrorKind::PermissionDenied,
"no raw code"
)));
}
#[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);
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");
}