tree-type-proc-macro 0.1.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 = std::env::temp_dir().join("tree_type_test_file");
    fs::create_dir_all(&temp_dir).unwrap();

    let tree = TestTree::new(&temp_dir);
    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");

    // Cleanup
    fs::remove_dir_all(&temp_dir).unwrap();
}

#[test]
fn test_directory_methods() {
    let temp_dir = std::env::temp_dir().join("tree_type_test_dir");

    // Clean up if exists from previous test
    let _ = fs::remove_dir_all(&temp_dir);

    let tree = TestTree::new(&temp_dir);
    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");

    // Cleanup
    fs::remove_dir_all(&temp_dir).unwrap();
}