From: Philipp Hufnagl <p.hufnagl@proxmox.com>
To: Lukas Wagner <l.wagner@proxmox.com>,
Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup v5 4/4] tests: check if include/exclude behavior works correctly
Date: Fri, 22 Dec 2023 10:45:43 +0100 [thread overview]
Message-ID: <437a089d-e8ae-44df-b8a8-ad611f22c2c6@proxmox.com> (raw)
In-Reply-To: <79bc00aa-eb74-4c63-a757-c1fb703350bd@proxmox.com>
On 12/19/23 14:23, Lukas Wagner wrote:
>
>
> 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 ;)
I'll try that. Thanks
>
>> + 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.
>
Yes, that makes the testing way more robust. Ill add this cases.
next prev parent reply other threads:[~2023-12-22 9:45 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
2023-12-22 9:45 ` Philipp Hufnagl [this message]
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=437a089d-e8ae-44df-b8a8-ad611f22c2c6@proxmox.com \
--to=p.hufnagl@proxmox.com \
--cc=l.wagner@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