use super::*;
#[test]
fn state_and_output_creation_refuse_other_current_or_legacy_workspaces() {
for marker in [
"index.artf",
"artifactize.json",
".artifactizeignore",
"file.txt.artf",
] {
let root = crate::test_os::tempdir();
let reviewed = root.path().join("reviewed");
let other = root.path().join("other");
std::fs::create_dir(&reviewed).unwrap();
std::fs::create_dir(&other).unwrap();
std::fs::write(other.join(marker), "marker").unwrap();
let state = other.join("state");
let error = prepare_directory(&state, &reviewed).unwrap_err();
assert!(
error.to_string().contains("outside artifactize workspaces"),
"{marker}: {error}"
);
assert!(!state.exists());
}
}
#[test]
fn workspace_marker_scan_refuses_an_unlistable_ancestor() {
#[cfg(unix)]
if crate::test_os::current_uid() == 0 {
return;
}
let root = crate::test_os::tempdir();
let reviewed = root.path().join("reviewed");
let other = root.path().join("other");
std::fs::create_dir(&reviewed).unwrap();
std::fs::create_dir(&other).unwrap();
std::fs::write(other.join("file.txt.artf"), "marker").unwrap();
let _permissions = crate::test_os::SearchOnlyDirectory::new(&other);
let state = other.join("state");
let error = prepare_directory(&state, &reviewed).unwrap_err();
assert_eq!(error.kind(), io::ErrorKind::PermissionDenied);
assert!(
error
.to_string()
.contains("Cannot inspect workspace markers"),
"{error}"
);
assert!(!state.exists());
}