From f8910f230be1f34e0c9876269b4939de24e695bf Mon Sep 17 00:00:00 2001 From: David Cantrell Date: Tue, 14 Jun 2022 22:27:47 +0100 Subject: [PATCH] tests for negative matching of files and folders --- src/context.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/context.rs b/src/context.rs index ee1361792..5ea86070e 100644 --- a/src/context.rs +++ b/src/context.rs @@ -777,6 +777,28 @@ mod tests { .is_match()); dont_match_ext.close()?; + let dont_match_file = testdir(&["goodfile", "evilfile"])?; + let dont_match_file_dc = DirContents::from_path(dont_match_file.path())?; + assert!(!ScanDir { + dir_contents: &dont_match_file_dc, + files: &["goodfile", "!notfound", "!evilfile"], + extensions: &[], + folders: &[], + } + .is_match()); + dont_match_file.close()?; + + let dont_match_folder = testdir(&["gooddir/somefile", "evildir/somefile"])?; + let dont_match_folder_dc = DirContents::from_path(dont_match_folder.path())?; + assert!(!ScanDir { + dir_contents: &dont_match_folder_dc, + files: &[], + extensions: &[], + folders: &["gooddir", "!notfound", "!evildir"], + } + .is_match()); + dont_match_folder.close()?; + Ok(()) }