Test some actual ignore caches

This commit is contained in:
Benjamin Sago 2017-09-28 19:00:01 +01:00
parent 476299e21f
commit 541e6855f2

View File

@ -125,6 +125,9 @@ mod test {
}
fn test_cache(dir: &'static str, pats: Vec<&str>) -> IgnoreCache {
IgnoreCache { entries: RwLock::new(vec![ (dir.into(), IgnorePatterns::parse_from_iter(pats.into_iter()).0) ]) }
}
#[test]
fn an_empty_cache_ignores_nothing() {
@ -132,4 +135,11 @@ mod test {
assert_eq!(false, ignores.is_ignored(Path::new("/usr/bin/drinking")));
assert_eq!(false, ignores.is_ignored(Path::new("target/debug/exa")));
}
#[test]
fn a_nonempty_cache_ignores_some_things() {
let ignores = test_cache("/vagrant", vec![ "target" ]);
assert_eq!(false, ignores.is_ignored(Path::new("/vagrant/src")));
assert_eq!(true, ignores.is_ignored(Path::new("/vagrant/target")));
}
}