From: Lukas Wagner <l.wagner@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>,
Philipp Hufnagl <p.hufnagl@proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup v5 4/4] tests: check if include/exclude behavior works correctly
Date: Tue, 19 Dec 2023 14:23:14 +0100 [thread overview]
Message-ID: <79bc00aa-eb74-4c63-a757-c1fb703350bd@proxmox.com> (raw)
In-Reply-To: <20231218153638.609440-5-p.hufnagl@proxmox.com>
On 12/18/23 16:36, Philipp Hufnagl wrote:
> 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(),
Just FIY, since GroupFilter implements FromStr, you can use the .parse
method on the string:
"...".parse::<GroupFilter>().unwrap();
The superfish (`::<Type>`) is probably not needed, since the type can be
inferred because you pass it to the split function ;)
> + 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
> + ));
> + }
> +}
Including tests is a great idea! I'd also add tests for all four cases:
- no filters
- only includes
- only excludes
- both
Right now, you've only covered the 'both' case.
--
- Lukas
next prev parent reply other threads:[~2023-12-19 13:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-18 15:36 [pbs-devel] [PATCH proxmox-backup v5 0/4] fix #4315: datastore: Exclude entries from sync Philipp Hufnagl
2023-12-18 15:36 ` [pbs-devel] [PATCH proxmox-backup v5 1/4] fix #4315: jobs: modify GroupFilter so include/exclude is tracked Philipp Hufnagl
2023-12-19 13:22 ` Lukas Wagner
2023-12-22 9:42 ` Philipp Hufnagl
2023-12-22 9:53 ` Lukas Wagner
2023-12-18 15:36 ` [pbs-devel] [PATCH proxmox-backup v5 2/4] ui: Show if Filter includes or excludes Philipp Hufnagl
2023-12-18 15:36 ` [pbs-devel] [PATCH proxmox-backup v5 3/4] docs: document new include/exclude paramenter Philipp Hufnagl
2023-12-18 15:36 ` [pbs-devel] [PATCH proxmox-backup v5 4/4] tests: check if include/exclude behavior works correctly Philipp Hufnagl
2023-12-19 13:23 ` Lukas Wagner [this message]
2023-12-22 9:45 ` Philipp Hufnagl
2023-12-19 13:25 ` [pbs-devel] [PATCH proxmox-backup v5 0/4] fix #4315: datastore: Exclude entries from sync Lukas Wagner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=79bc00aa-eb74-4c63-a757-c1fb703350bd@proxmox.com \
--to=l.wagner@proxmox.com \
--cc=p.hufnagl@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox