mirror of
https://git.proxmox.com/git/pathpatterns
synced 2025-07-13 18:24:49 +00:00
tests for relative and absolute, anchored and unanchored mixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
51f5c11e2b
commit
2faab5045a
@ -488,3 +488,36 @@ fn test_literal_matches() {
|
|||||||
)];
|
)];
|
||||||
assert_eq!(matchlist.matches("/bin/mv", None), Some(MatchType::Include));
|
assert_eq!(matchlist.matches("/bin/mv", None), Some(MatchType::Include));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_path_relativity() {
|
||||||
|
use crate::Pattern;
|
||||||
|
let matchlist = vec![
|
||||||
|
MatchEntry::new(Pattern::path("noslash").unwrap(), MatchType::Include),
|
||||||
|
MatchEntry::new(Pattern::path("noslash-a").unwrap(), MatchType::Include)
|
||||||
|
.flags(MatchFlag::ANCHORED),
|
||||||
|
MatchEntry::new(Pattern::path("/slash").unwrap(), MatchType::Include),
|
||||||
|
MatchEntry::new(Pattern::path("/slash-a").unwrap(), MatchType::Include)
|
||||||
|
.flags(MatchFlag::ANCHORED),
|
||||||
|
];
|
||||||
|
assert_eq!(matchlist.matches("noslash", None), Some(MatchType::Include));
|
||||||
|
assert_eq!(
|
||||||
|
matchlist.matches("noslash-a", None),
|
||||||
|
Some(MatchType::Include)
|
||||||
|
);
|
||||||
|
assert_eq!(matchlist.matches("slash", None), None);
|
||||||
|
assert_eq!(matchlist.matches("/slash", None), Some(MatchType::Include));
|
||||||
|
assert_eq!(matchlist.matches("slash-a", None), None);
|
||||||
|
assert_eq!(
|
||||||
|
matchlist.matches("/slash-a", None),
|
||||||
|
Some(MatchType::Include)
|
||||||
|
);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
matchlist.matches("foo/noslash", None),
|
||||||
|
Some(MatchType::Include)
|
||||||
|
);
|
||||||
|
assert_eq!(matchlist.matches("foo/noslash-a", None), None);
|
||||||
|
assert_eq!(matchlist.matches("foo/slash", None), None);
|
||||||
|
assert_eq!(matchlist.matches("foo/slash-a", None), None);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user