File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -303,7 +303,11 @@ impl From<NaiveDateTime> for Minute {
303303impl Minute {
304304 /// Convert minutes to a slot range
305305 /// e.g. given minute = 15 and OBJECT_STORE_DATA_GRANULARITY = 10 returns "10-19"
306+ ///
307+ /// ### PANICS
308+ /// If the provided `data_granularity` value isn't cleanly divisble from 60
306309 pub fn to_slot ( self , data_granularity : u32 ) -> String {
310+ assert ! ( data_granularity % 60 == 0 ) ;
307311 let block_n = self . block / data_granularity;
308312 let block_start = block_n * data_granularity;
309313 if data_granularity == 1 {
@@ -500,4 +504,10 @@ mod tests {
500504 let timestamp = NaiveDateTime :: parse_from_str ( "2025-01-01 02:33" , "%Y-%m-%d %H:%M" ) . unwrap ( ) ;
501505 assert_eq ! ( Minute :: from( timestamp) . to_slot( 30 ) , "30-59" ) ;
502506 }
507+
508+ #[ test]
509+ #[ should_panic]
510+ fn illegal_slot_granularity ( ) {
511+ Minute :: try_from ( 0 ) . unwrap ( ) . to_slot ( 40 ) ;
512+ }
503513}
You can’t perform that action at this time.
0 commit comments