use super::*;
use crate::test_support::{fixture, remove};
#[test]
fn every_entry_counts_once_and_links_are_not_followed() {
let parent: PathBuf = fixture("entry-count-kinds");
let root: PathBuf = parent.join("tree");
let nested: PathBuf = root.join("a").join("b");
std::fs::create_dir_all(&nested).expect("nested directories");
std::fs::create_dir(root.join("empty")).expect("empty directory");
let files: u64 = 5;
for number in 0..files {
std::fs::write(nested.join(format!("file-{number}")), b"x").expect("file");
}
std::os::unix::fs::symlink(root.join("a"), root.join("link")).expect("link");
let expected: u64 = 4 + files;
assert_eq!(count_entries(root.as_path()), expected);
remove(parent.as_path());
}
#[test]
fn a_missing_root_and_a_plain_file_count_nothing() {
let parent: PathBuf = fixture("entry-count-nothing");
assert_eq!(count_entries(parent.join("absent").as_path()), 0);
std::fs::write(parent.join("file"), b"x").expect("file");
assert_eq!(count_entries(parent.join("file").as_path()), 0);
remove(parent.as_path());
}