Skip to content

Commit

Permalink
Fix test_time_zone_from_posix_tz in environments without a tzdb
Browse files Browse the repository at this point in the history
  • Loading branch information
pitdicker committed Aug 31, 2023
1 parent a739648 commit 34ca0b4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/offset/local/tz_info/timezone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,12 @@ mod tests {
assert_eq!(time_zone_local, time_zone_local_1);
}

let time_zone_utc = TimeZone::from_posix_tz("UTC")?;
assert_eq!(time_zone_utc.find_local_time_type(0)?.offset(), 0);
// `TimeZone::from_posix_tz("UTC")` will return `Error` if the environment does not have
// a time zone database, like for example some docker containers.
// In that case skip the test.
if let Ok(time_zone_utc) = TimeZone::from_posix_tz("UTC") {
assert_eq!(time_zone_utc.find_local_time_type(0)?.offset(), 0);
}

Check warning on line 867 in src/offset/local/tz_info/timezone.rs

View check run for this annotation

Codecov / codecov/patch

src/offset/local/tz_info/timezone.rs#L867

Added line #L867 was not covered by tests
}

assert!(TimeZone::from_posix_tz("EST5EDT,0/0,J365/25").is_err());
Expand Down

0 comments on commit 34ca0b4

Please sign in to comment.