@@ -471,25 +471,25 @@ fn fixup_bounds(
471
471
fn check_bounds ( start : & Option < Bound > , end : & Option < Bound > ) -> anyhow:: Result < ( ) > {
472
472
// current UTC date
473
473
let current = Utc :: today ( ) ;
474
- match start . as_ref ( ) . zip ( end. as_ref ( ) ) {
474
+ match ( start , end) {
475
475
// start date is after end date
476
- Some ( ( Bound :: Date ( start) , Bound :: Date ( end) ) ) if end < start => {
476
+ ( Some ( Bound :: Date ( start) ) , Some ( Bound :: Date ( end) ) ) if end < start => {
477
477
bail ! (
478
478
"end should be after start, got start: {} and end {}" ,
479
479
start,
480
480
end
481
481
) ;
482
482
}
483
483
// start date is after current date
484
- Some ( ( Bound :: Date ( start) , _) ) if start > & current => {
484
+ ( Some ( Bound :: Date ( start) ) , _) if start > & current => {
485
485
bail ! (
486
486
"start date should be on or before current date, got start date request: {} and current date is {}" ,
487
487
start,
488
488
current
489
489
) ;
490
490
}
491
491
// end date is after current date
492
- Some ( ( _, Bound :: Date ( end) ) ) if end > & current => {
492
+ ( _, Some ( Bound :: Date ( end) ) ) if end > & current => {
493
493
bail ! (
494
494
"end date should be on or before current date, got start date request: {} and current date is {}" ,
495
495
end,
@@ -1202,13 +1202,25 @@ mod tests {
1202
1202
assert ! ( check_bounds( & Some ( Bound :: Date ( start) ) , & Some ( Bound :: Date ( end) ) ) . is_err( ) ) ;
1203
1203
}
1204
1204
1205
+ #[ test]
1206
+ fn test_check_bounds_invalid_start_after_current_without_end ( ) {
1207
+ let start = chrono:: Utc :: today ( ) . succ ( ) ;
1208
+ assert ! ( check_bounds( & Some ( Bound :: Date ( start) ) , & None ) . is_err( ) ) ;
1209
+ }
1210
+
1205
1211
#[ test]
1206
1212
fn test_check_bounds_invalid_end_after_current ( ) {
1207
1213
let start = chrono:: Utc :: today ( ) ;
1208
1214
let end = chrono:: Utc :: today ( ) . succ ( ) ;
1209
1215
assert ! ( check_bounds( & Some ( Bound :: Date ( start) ) , & Some ( Bound :: Date ( end) ) ) . is_err( ) ) ;
1210
1216
}
1211
1217
1218
+ #[ test]
1219
+ fn test_check_bounds_invalid_end_after_current_without_start ( ) {
1220
+ let end = chrono:: Utc :: today ( ) . succ ( ) ;
1221
+ assert ! ( check_bounds( & None , & Some ( Bound :: Date ( end) ) ) . is_err( ) ) ;
1222
+ }
1223
+
1212
1224
#[ test]
1213
1225
fn test_nightly_finder_iterator ( ) {
1214
1226
let start_date = Date :: from_utc ( NaiveDate :: from_ymd ( 2019 , 01 , 01 ) , Utc ) ;
0 commit comments