[pbs-devel] [PATCH proxmox 3/3] time: Add more calendat event tests

Maximiliano Sandoval m.sandoval at proxmox.com
Wed Aug 13 13:03:27 CEST 2025


Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
---
 proxmox-time/src/calendar_event.rs | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/proxmox-time/src/calendar_event.rs b/proxmox-time/src/calendar_event.rs
index edb258ba..8222bcec 100644
--- a/proxmox-time/src/calendar_event.rs
+++ b/proxmox-time/src/calendar_event.rs
@@ -477,8 +477,14 @@ mod tests {
         use std::str::FromStr;
 
         assert!(CalendarEvent::from_str("15:30").is_ok());
+        assert!(CalendarEvent::from_str("0").is_ok());
+        assert!(CalendarEvent::from_str("59").is_ok());
+        assert!(CalendarEvent::from_str("15:30:59").is_ok());
 
         assert!(CalendarEvent::from_str("40:00").is_err());
+        assert!(CalendarEvent::from_str("60").is_err());
+        assert!(CalendarEvent::from_str("24:61").is_err());
+        assert!(CalendarEvent::from_str("15:30:60").is_err());
     }
 
     #[test]
@@ -494,6 +500,10 @@ mod tests {
             }
         );
 
+        assert!(parse_time_spec("1:00:00").is_ok());
+        assert!(parse_time_spec("1:00").is_ok());
+        assert!(parse_time_spec("59").is_ok());
+
         // These do not strictly fail, but should fail when parsed with FromStr
         // since there will be input left to consume.
         let (input, data) = parse_time_spec("40:00").unwrap();
@@ -506,5 +516,23 @@ mod tests {
                 second: vec![DateTimeValue::Single(0)]
             }
         );
+
+        assert!(parse_time_spec("61").is_err());
+        // This should be 1:00 instead.
+        assert!(parse_time_spec("60").is_err());
+
+        // Can only partially parse
+        let (input, _data) = parse_time_spec("24:61").unwrap();
+        assert_eq!(input, ":61");
+
+
+        assert_eq!(
+            data,
+            TimeSpec {
+                hour: vec![],
+                minute: vec![DateTimeValue::Single(40)],
+                second: vec![DateTimeValue::Single(0)]
+            }
+        );
     }
 }
-- 
2.47.2





More information about the pbs-devel mailing list