Avoid failing format test with current date (#10068)

Replace the test that tested with
`chrono::offset::Local::now().naive_local()` taken, failing the
formatting once per year at least.


Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2024-04-02 10:37:14 +02:00 committed by GitHub
parent 1da2441e7b
commit c15b9d4e1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -296,15 +296,19 @@ mod tests {
} }
#[test] #[test]
fn test_format_distance_from_now() { fn test_format_distance_from_hms() {
let date = DateTimeType::Naive( let date = DateTimeType::Naive(
NaiveDateTime::parse_from_str("1969-07-20T00:00:00Z", "%Y-%m-%dT%H:%M:%SZ") NaiveDateTime::parse_from_str("1969-07-20T11:22:33Z", "%Y-%m-%dT%H:%M:%SZ")
.expect("Invalid NaiveDateTime for date"), .expect("Invalid NaiveDateTime for date"),
); );
let base_date = DateTimeType::Naive(
NaiveDateTime::parse_from_str("2024-02-01T00:00:00Z", "%Y-%m-%dT%H:%M:%SZ")
.expect("Invalid NaiveDateTime for base_date"),
);
assert_eq!( assert_eq!(
"over 54 years ago", "over 54 years ago",
format_distance_from_now(date, false, true, false) format_distance(date, base_date.to_naive(), false, true, false)
); );
} }