Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Avoid failing format test with current date (#10068)

Kirill Bulatovc15b9d4e1c6e
diff --git a/crates/ui/src/utils/format_distance.rs b/crates/ui/src/utils/format_distance.rs
index 03a0de3adb7..14f3237e560 100644
--- a/crates/ui/src/utils/format_distance.rs
+++ b/crates/ui/src/utils/format_distance.rs
@@ -296,15 +296,19 @@ mod tests {
}
#[test]
- fn test_format_distance_from_now() {
+ fn test_format_distance_from_hms() {
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"),
);
+ 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!(
"over 54 years ago",
- format_distance_from_now(date, false, true, false)
+ format_distance(date, base_date.to_naive(), false, true, false)
);
}