mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-05 04:14:53 +00:00
Initialize exclude using Default and field overwriting
This commit is contained in:
parent
fa1952dd98
commit
14d47d9108
1 changed files with 11 additions and 5 deletions
|
|
@ -175,8 +175,11 @@ mod test {
|
|||
let includes = Some(Includes {
|
||||
regex: Some(RegexSet::new(&[r"foo.example.org"]).unwrap()),
|
||||
});
|
||||
let mut excludes = Excludes::default();
|
||||
excludes.regex = Some(RegexSet::new(&[r"example.org"]).unwrap());
|
||||
let excludes = Excludes {
|
||||
regex: Some(RegexSet::new(&[r"example.org"]).unwrap()),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let filter = Filter::new(includes, Some(excludes), None);
|
||||
|
||||
assert_eq!(filter.excluded(&request("https://foo.example.org")), false);
|
||||
|
|
@ -186,9 +189,12 @@ mod test {
|
|||
|
||||
#[test]
|
||||
fn test_exclude_regex() {
|
||||
let mut excludes = Excludes::default();
|
||||
excludes.regex =
|
||||
Some(RegexSet::new(&[r"github.com", r"[a-z]+\.(org|net)", r"@example.org"]).unwrap());
|
||||
let excludes = Excludes {
|
||||
regex: Some(
|
||||
RegexSet::new(&[r"github.com", r"[a-z]+\.(org|net)", r"@example.org"]).unwrap(),
|
||||
),
|
||||
..Default::default()
|
||||
};
|
||||
let filter = Filter::new(None, Some(excludes), None);
|
||||
|
||||
assert_eq!(filter.excluded(&request("http://github.com")), true);
|
||||
|
|
|
|||
Loading…
Reference in a new issue