use std::path::Path;

use treehouse::vfs::{entries, query, Content, PhysicalDir, VPath, VPathBuf};

fn vfs() -> PhysicalDir {
    let root = Path::new("tests/it/vfs_physical").to_path_buf();
    PhysicalDir::new(root)
}

#[test]
fn dir() {
    let vfs = vfs();
    let dir = entries(&vfs, VPath::ROOT);
    assert_eq!(&dir[..], &[VPathBuf::new("test.txt")]);
}

#[test]
fn content() {
    let vfs = vfs();
    let content = query::<Content>(&vfs, VPath::new("test.txt")).map(Content::bytes);
    assert_eq!(content.as_deref(), Some(b"hewwo :3\n".as_slice()));
}
