use crate::testing_prelude::*;
#[test]
fn temp_directory_create() {
let temp = TempDirectory::create("create_test");
assert!(temp.exists(), "directory should exist after create");
}
#[test]
fn temp_directory_drop() {
let path = {
let temp = TempDirectory::create("drop_test");
assert!(temp.exists());
temp.to_path_buf()
};
assert!(!path.exists(), "directory should be deleted after drop");
}
#[test]
fn temp_directory_keep() {
let path = {
let temp = TempDirectory::create("keep_test").keep();
assert!(temp.exists());
temp.to_path_buf()
};
assert!(path.exists(), "directory should still exist after drop");
remove_dir_all(&path).expect("cleanup");
}
#[test]
fn temp_directory_to_path_buf() {
let path = {
let temp = TempDirectory::create("to_path_buf_test");
let p = temp.to_path_buf();
assert!(p.exists());
p
};
assert!(!path.exists(), "directory should be deleted after drop");
}
#[test]
fn temp_directory_deref() {
let temp = TempDirectory::create("deref_test");
let joined = temp.join("subdir");
assert!(joined.starts_with(&temp));
}
#[test]
fn temp_directory_create_unique_paths() {
let temp1 = TempDirectory::create("unique_test");
let temp2 = TempDirectory::create("unique_test");
assert_ne!(
temp1.to_path_buf(),
temp2.to_path_buf(),
"paths should be unique"
);
}