#![allow(deprecated)]
use std::fs;
use tree_type::tree_type;
#[test]
#[cfg(unix)]
fn test_nested_path_symlink() {
tree_type! {
TestRoot {
a/ {
b/ {
c/ {
#[default("nested content")]
target("target.txt")
}
}
},
links/ {
#[symlink(/a/b/c/target)]
deep_link("link.txt")
}
}
}
let temp_dir = tempfile::tempdir().unwrap();
let root = TestRoot::new(temp_dir.path()).unwrap();
root.a().b().c().target().write("nested content").unwrap();
root.sync().unwrap();
let link = root.links().deep_link();
assert!(link.exists(), "Nested path symlink should exist");
let metadata = fs::symlink_metadata(link.as_path()).unwrap();
assert!(metadata.is_symlink(), "Should be a symlink");
let content = link.read_to_string().unwrap();
assert_eq!(content, "nested content");
}