Skip to content

Commit d48444d

Browse files
committed
add test
1 parent dc70324 commit d48444d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/ignore_path.rs

+23
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ impl IgnorePathSet {
3030
}
3131
}
3232
}
33+
34+
#[cfg(test)]
35+
mod test {
36+
use crate::config::{Config, FileName};
37+
use crate::ignore_path::IgnorePathSet;
38+
use std::path::PathBuf;
39+
40+
#[test]
41+
fn test_ignore_path_set() {
42+
let config = Config::from_toml(
43+
"ignore = [
44+
\"foo.rs\",
45+
\"bar_dir/*\",
46+
]",
47+
)
48+
.unwrap();
49+
let ignore_path_set = IgnorePathSet::from_ignore_list(&config.ignore()).unwrap();
50+
51+
assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("src/foo.rs"))));
52+
assert!(ignore_path_set.is_match(&FileName::Real(PathBuf::from("bar_dir/baz.rs"))));
53+
assert!(!ignore_path_set.is_match(&FileName::Real(PathBuf::from("src/bar.rs"))));
54+
}
55+
}

0 commit comments

Comments
 (0)