2024-11-08 14:52:32 +01:00
|
|
|
use std::path::Path;
|
|
|
|
|
2024-11-29 20:03:32 +01:00
|
|
|
use treehouse::vfs::{entries, query, Content, PhysicalDir, VPath, VPathBuf};
|
2024-11-08 14:52:32 +01:00
|
|
|
|
|
|
|
fn vfs() -> PhysicalDir {
|
|
|
|
let root = Path::new("tests/it/vfs_physical").to_path_buf();
|
|
|
|
PhysicalDir::new(root)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn dir() {
|
|
|
|
let vfs = vfs();
|
2024-11-29 20:03:32 +01:00
|
|
|
let dir = entries(&vfs, VPath::ROOT);
|
|
|
|
assert_eq!(&dir[..], &[VPathBuf::new("test.txt")]);
|
2024-11-08 14:52:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn content() {
|
|
|
|
let vfs = vfs();
|
2024-11-29 20:03:32 +01:00
|
|
|
let content = query::<Content>(&vfs, VPath::new("test.txt")).map(Content::bytes);
|
2024-11-08 14:52:32 +01:00
|
|
|
assert_eq!(content.as_deref(), Some(b"hewwo :3\n".as_slice()));
|
|
|
|
}
|