From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 08F4A1FF0E0 for ; Thu, 09 Jul 2026 13:57:43 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A1A26214DA; Thu, 09 Jul 2026 13:57:33 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com Subject: [PATCH proxmox 07/29] notify: matcher: calendar: add basic unit test Date: Thu, 9 Jul 2026 13:56:54 +0200 Message-ID: <20260709115716.299836-8-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260709115716.299836-1-l.wagner@proxmox.com> References: <20260709115716.299836-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783598238347 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.000 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: 7PW62N7YCLFBB6U3PUTAELV3OD6OAHH6 X-Message-ID-Hash: 7PW62N7YCLFBB6U3PUTAELV3OD6OAHH6 X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Just a basic smoke test to ensure that the matcher can be constructed from from a calendar expression. Signed-off-by: Lukas Wagner --- proxmox-notify/src/matcher/calendar.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/proxmox-notify/src/matcher/calendar.rs b/proxmox-notify/src/matcher/calendar.rs index 5deab13e..970801c5 100644 --- a/proxmox-notify/src/matcher/calendar.rs +++ b/proxmox-notify/src/matcher/calendar.rs @@ -44,3 +44,26 @@ impl FromStr for CalendarMatcher { proxmox_serde::forward_deserialize_to_from_str!(CalendarMatcher); proxmox_serde::forward_serialize_to_display!(CalendarMatcher); + +#[cfg(test)] +mod test { + use serde_json::Value; + + use crate::{Notification, Severity, matcher::MatchDirective as _}; + + use super::*; + + #[test] + fn test_calendar_matcher() { + let mut notification = + Notification::from_template(Severity::Notice, "test", Value::Null, Default::default()); + + // Fr 22 Mai 2026 12:45:00 CEST + notification.metadata.timestamp = 1779446700; + + // Match on a wide rage to avoid issues when running this test case + // in a different time zone. + let matcher: CalendarMatcher = "thu..sat 0-23".parse().unwrap(); + assert!(matcher.matches(¬ification).unwrap()); + } +} -- 2.47.3