From 6d96ca828842e88b01e4c8d2d4883163251ca395 Mon Sep 17 00:00:00 2001 From: adlee-was-taken Date: Tue, 28 Apr 2026 19:48:50 -0400 Subject: [PATCH] test(cli): humanize_age bucket boundaries + plural transitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Locks the singular vs plural transition (1 minute ago vs 2 minutes ago) and each bucket boundary (59→60s minutes, 3599→3600s hours, 86400→86400×2 days, etc.) so future tweaks can't silently regress the user-facing labels. --- crates/relicario-cli/src/helpers.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/relicario-cli/src/helpers.rs b/crates/relicario-cli/src/helpers.rs index a864f95..2e7b43b 100644 --- a/crates/relicario-cli/src/helpers.rs +++ b/crates/relicario-cli/src/helpers.rs @@ -118,4 +118,21 @@ mod tests { // 2026-04-19T00:00:00Z = 1776556800 assert_eq!(iso8601(1_776_556_800), "2026-04-19T00:00:00Z"); } + + #[test] + fn humanize_age_buckets() { + assert_eq!(humanize_age(0), "just now"); + assert_eq!(humanize_age(59), "just now"); + assert_eq!(humanize_age(60), "1 minute ago"); + assert_eq!(humanize_age(120), "2 minutes ago"); + assert_eq!(humanize_age(3_599), "59 minutes ago"); + assert_eq!(humanize_age(3_600), "1 hour ago"); + assert_eq!(humanize_age(7_200), "2 hours ago"); + assert_eq!(humanize_age(86_400), "1 day ago"); + assert_eq!(humanize_age(86_400 * 2), "2 days ago"); + assert_eq!(humanize_age(86_400 * 30), "1 month ago"); + assert_eq!(humanize_age(86_400 * 60), "2 months ago"); + assert_eq!(humanize_age(86_400 * 365), "1 year ago"); + assert_eq!(humanize_age(86_400 * 365 * 3), "3 years ago"); + } }