From 868c8a695fa532ac52335d7c8817d969266e8ba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Fri, 23 Oct 2026 15:35:50 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20test:=20forge-core=20keeps=20its=20?= =?UTF-8?q?stamp=20ordering=20and=20closing=20keyword=20spec=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Restores stamps_sort_lexicographically_in_time_order (time.rs tests module) and all_keywords_are_case_insensitive (issue_refs.rs), both removed in the phase 2 deletion. Tests: 307 before, 309 after. --- crates/forge-core/src/issue_refs.rs | 10 ++++++++++ crates/forge-core/src/time.rs | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/crates/forge-core/src/issue_refs.rs b/crates/forge-core/src/issue_refs.rs index b68df1a..d8d93b7 100644 --- a/crates/forge-core/src/issue_refs.rs +++ b/crates/forge-core/src/issue_refs.rs @@ -152,4 +152,14 @@ mod tests { assert_eq!(find_closing_refs(text), *want, "case {text:?}"); } } + + #[test] + fn all_keywords_are_case_insensitive() { + for kw in [ + "close", "closes", "closed", "fix", "fixes", "fixed", "resolve", "resolves", "resolved", + ] { + let text = format!("{}: #5", kw.to_uppercase()); + assert_eq!(find_closing_refs(&text), vec![5], "{kw}"); + } + } } diff --git a/crates/forge-core/src/time.rs b/crates/forge-core/src/time.rs index 2178e69..0eca2c3 100644 --- a/crates/forge-core/src/time.rs +++ b/crates/forge-core/src/time.rs @@ -46,3 +46,31 @@ pub fn stamp_to_unix(stamp: &str) -> Option { .ok() .map(OffsetDateTime::unix_timestamp) } + +#[cfg(test)] +mod tests { + use super::*; + + fn is_valid_stamp(s: &str) -> bool { + let b = s.as_bytes(); + b.len() == 30 + && b[4] == b'-' + && b[7] == b'-' + && b[10] == b'T' + && b[13] == b':' + && b[16] == b':' + && b[19] == b'.' + && b[29] == b'Z' + && b[20..29].iter().all(u8::is_ascii_digit) + } + + #[test] + fn stamps_sort_lexicographically_in_time_order() { + let a = now_stamp(); + let b = stamp_after(Duration::from_secs(3600)); + assert!(is_valid_stamp(&b), "bad stamp: {b}"); + assert!(a < b); + let c = stamp_after(Duration::from_secs(7200)); + assert!(b < c); + } +}