···
436
436
Ok(()) // Always succeed.
437
437
}
438
438
}
439
439
+
440
440
+
#[test]
441
441
+
fn test_in_memory_dir_walking() -> Result<(), Error> {
442
442
+
use itertools::Itertools;
443
443
+
let imfs = InMemoryFileSystem::new();
444
444
+
imfs.write(&Utf8PathBuf::from("/a/b/a.txt"), "a")?;
445
445
+
imfs.write(&Utf8PathBuf::from("/a/b/b.txt"), "a")?;
446
446
+
imfs.write(&Utf8PathBuf::from("/a/b/c.txt"), "a")?;
447
447
+
imfs.write(&Utf8PathBuf::from("/b/d.txt"), "a")?;
448
448
+
imfs.write(&Utf8PathBuf::from("/a/c/e.txt"), "a")?;
449
449
+
imfs.write(&Utf8PathBuf::from("/a/c/d/f.txt"), "a")?;
450
450
+
imfs.write(&Utf8PathBuf::from("/a/g.txt"), "a")?;
451
451
+
imfs.write(&Utf8PathBuf::from("/h.txt"), "a")?;
452
452
+
imfs.mkdir(&Utf8PathBuf::from("/a/e"))?;
453
453
+
454
454
+
let mut walked_entries: Vec<String> = DirWalker::new(Utf8PathBuf::from("/a/"))
455
455
+
.into_file_iter(&imfs)
456
456
+
.map_ok(Utf8PathBuf::into_string)
457
457
+
.try_collect()?;
458
458
+
459
459
+
// Keep test deterministic due to hash map usage
460
460
+
walked_entries.sort();
461
461
+
462
462
+
assert_eq!(
463
463
+
vec![
464
464
+
"/a/b/a.txt".to_owned(),
465
465
+
"/a/b/b.txt".to_owned(),
466
466
+
"/a/b/c.txt".to_owned(),
467
467
+
"/a/c/d/f.txt".to_owned(),
468
468
+
"/a/c/e.txt".to_owned(),
469
469
+
"/a/g.txt".to_owned(),
470
470
+
],
471
471
+
walked_entries,
472
472
+
);
473
473
+
474
474
+
Ok(())
475
475
+
}