Skip to content

Commit ad4aa52

Browse files
committed
test(vfs): add regression test for OverlayFs::read_dir on file path
Directly tests that read_dir returns Err for file paths, per spec requirement (specs/003-vfs.md line 459).
1 parent 6e671ff commit ad4aa52

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

crates/bashkit/src/fs/overlay.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,20 @@ mod tests {
11541154
assert!(names.contains(&&"upper.txt".to_string()));
11551155
}
11561156

1157+
/// Regression: read_dir on a file must return Err, not Ok(vec![])
1158+
#[tokio::test]
1159+
async fn test_read_dir_on_file_returns_error() {
1160+
let lower = Arc::new(InMemoryFs::new());
1161+
lower
1162+
.write_file(Path::new("/tmp/file.txt"), b"data")
1163+
.await
1164+
.unwrap();
1165+
1166+
let overlay = OverlayFs::new(lower);
1167+
let result = overlay.read_dir(Path::new("/tmp/file.txt")).await;
1168+
assert!(result.is_err(), "read_dir on a file should return Err");
1169+
}
1170+
11571171
// Issue #418: usage should deduct whited-out files
11581172
#[tokio::test]
11591173
async fn test_usage_deducts_whiteouts() {

0 commit comments

Comments
 (0)