[pbs-devel] [PATCH proxmox-backup v5 4/4] tests: check if include/exclude behavior works correctly
Philipp Hufnagl
p.hufnagl at proxmox.com
Mon Dec 18 16:36:38 CET 2023
This checks if including and excluding works as expected. That the
filter are added out of order is on purpose since it sould make no
difference.
Signed-off-by: Philipp Hufnagl <p.hufnagl at proxmox.com>
---
tests/sync_jobs.rs | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 tests/sync_jobs.rs
diff --git a/tests/sync_jobs.rs b/tests/sync_jobs.rs
new file mode 100644
index 00000000..83877160
--- /dev/null
+++ b/tests/sync_jobs.rs
@@ -0,0 +1,34 @@
+use pbs_api_types::{
+ apply_filters, split_by_include_exclude, BackupGroup, BackupType, GroupFilter,
+};
+use std::str::FromStr;
+
+#[test]
+fn test_group_filters() {
+ let group_filters = vec![
+ GroupFilter::from_str("exclude:regex:.*10[1-3]").unwrap(),
+ GroupFilter::from_str("regex:.*10[2-8]").unwrap(),
+ GroupFilter::from_str("exclude:regex:.*10[5-7]").unwrap(),
+ ];
+ let (include_filters, exclude_filters) = split_by_include_exclude(Some(group_filters));
+
+ let dont_backup = vec![
+ "vm/101", "vm/102", "vm/103", "vm/105", "vm/106", "vm/107", "vm/109",
+ ];
+ for id in dont_backup {
+ assert!(!apply_filters(
+ &BackupGroup::new(BackupType::Vm, id),
+ &include_filters,
+ &exclude_filters
+ ));
+ }
+
+ let do_backup = vec!["vm/104", "vm/108"];
+ for id in do_backup {
+ assert!(apply_filters(
+ &BackupGroup::new(BackupType::Vm, id),
+ &include_filters,
+ &exclude_filters
+ ));
+ }
+}
--
2.39.2
More information about the pbs-devel
mailing list