50 lines
1.3 KiB
Rust
50 lines
1.3 KiB
Rust
use std::path::Path;
|
|
|
|
use treehouse::vfs::{
|
|
file::BufferedFile, mount_points::MountPoints, physical::PhysicalDir, DirEntry, ReadFilesystem,
|
|
VPath, VPathBuf,
|
|
};
|
|
|
|
fn vfs() -> MountPoints {
|
|
let file1 = BufferedFile::new(b"hewwo :3".to_vec());
|
|
let file2 = BufferedFile::new(b"fwoofee -w-".to_vec());
|
|
let file3 = BufferedFile::new(b"boop >w<".to_vec());
|
|
|
|
let mut inner = MountPoints::new();
|
|
inner.add(VPath::new("file3.txt"), Box::new(file3));
|
|
|
|
let mut vfs = MountPoints::new();
|
|
vfs.add(VPath::new("file1.txt"), Box::new(file1));
|
|
vfs.add(VPath::new("file2.txt"), Box::new(file2));
|
|
vfs.add(VPath::new("inner"), Box::new(inner));
|
|
vfs
|
|
}
|
|
|
|
#[test]
|
|
fn dir() {
|
|
let vfs = vfs();
|
|
|
|
assert_eq!(
|
|
vfs.dir(VPath::new("")),
|
|
vec![
|
|
DirEntry {
|
|
path: VPathBuf::new("file1.txt"),
|
|
},
|
|
DirEntry {
|
|
path: VPathBuf::new("file2.txt"),
|
|
},
|
|
DirEntry {
|
|
path: VPathBuf::new("inner"),
|
|
}
|
|
]
|
|
);
|
|
|
|
assert!(vfs.dir(VPath::new("file1.txt")).is_empty());
|
|
assert!(vfs.dir(VPath::new("file2.txt")).is_empty());
|
|
assert_eq!(
|
|
vfs.dir(VPath::new("inner")),
|
|
vec![DirEntry {
|
|
path: VPathBuf::new("file3.txt")
|
|
}]
|
|
);
|
|
}
|