Skip to content

Commit

Permalink
Extract date value to avoid multi-line match scrutinee
Browse files Browse the repository at this point in the history
  • Loading branch information
djc committed Oct 3, 2022
1 parent 0d45147 commit ab43d61
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions tests/dateutils.rs
Expand Up @@ -33,12 +33,9 @@ fn verify_against_date_command_local(path: &'static str, dt: NaiveDateTime) {
// This is used while a decision is made wheter the `date` output needs to
// be exactly matched, or whether LocalResult::Ambigious should be handled
// differently
match Local.from_local_datetime(
&NaiveDate::from_ymd_opt(dt.year(), dt.month(), dt.day())
.unwrap()
.and_hms_opt(dt.hour(), 5, 1)
.unwrap(),
) {

let date = NaiveDate::from_ymd_opt(dt.year(), dt.month(), dt.day()).unwrap();
match Local.from_local_datetime(&date.and_hms_opt(dt.hour(), 5, 1).unwrap()) {
chrono::LocalResult::Ambiguous(a, b) => assert!(
format!("{}\n", a) == date_command_str || format!("{}\n", b) == date_command_str
),
Expand Down

0 comments on commit ab43d61

Please sign in to comment.