tree-type-proc-macro 0.2.0

Procedural macros for tree-type crate
Documentation
use std::fs;
use tree_type_proc_macro::tree_type;

tree_type! {
    TestTree {
        test_file,
        test_dir/ {
            nested_file
        }
    }
}

#[test]
fn test_file_methods() {
    let temp_dir = tempfile::tempdir().unwrap();
    let root = temp_dir.path().join("tree_type_test_file");
    fs::create_dir_all(&root).unwrap();

    let tree = TestTree::new(&root).unwrap();
    let file = tree.test_file();

    // Test exists (should be false initially)
    assert!(!file.exists());

    // Test write
    file.write("hello world").unwrap();

    // Test exists (should be true now)
    assert!(file.exists());

    // Test read
    let content = file.read_to_string().unwrap();
    assert_eq!(content, "hello world");
}

#[test]
fn test_directory_methods() {
    let temp_dir = tempfile::tempdir().unwrap();
    let root = temp_dir.path().join("tree_type_test_file");

    let tree = TestTree::new(&root).unwrap();
    let dir = tree.test_dir();

    // Test exists (should be false initially)
    assert!(!dir.exists());

    // Test create_all
    dir.create_all().unwrap();

    // Test exists (should be true now)
    assert!(dir.exists());

    // Test nested file access
    let nested = dir.nested_file();
    nested.write("nested content").unwrap();
    assert_eq!(nested.read_to_string().unwrap(), "nested content");
}