diff --git a/crates/forge-web-app/src/ci/live.rs b/crates/forge-web-app/src/ci/live.rs index e6b3454..cd0871f 100644 --- a/crates/forge-web-app/src/ci/live.rs +++ b/crates/forge-web-app/src/ci/live.rs @@ -199,16 +199,6 @@ mod tests { assert!(!run.has_changed().expect("open")); } - #[test] - fn a_bump_drops_the_entry_once_its_last_receiver_is_gone() { - let live = CiLive::default(); - let rx = live.subscribe_job("job-1"); - assert_eq!(live.jobs.counters().len(), 1); - drop(rx); - live.bump_job("job-1"); - assert!(live.jobs.counters().is_empty()); - } - #[tokio::test] async fn a_runner_wakes_the_pages_only_when_its_online_state_changes() { let live = CiLive::default(); diff --git a/crates/forge-web-app/src/ci/metrics_chart.rs b/crates/forge-web-app/src/ci/metrics_chart.rs index c209daa..d5f48f7 100644 --- a/crates/forge-web-app/src/ci/metrics_chart.rs +++ b/crates/forge-web-app/src/ci/metrics_chart.rs @@ -251,15 +251,4 @@ mod tests { assert_eq!(d.matches('M').count(), 2, "{d}"); assert_eq!(d.matches('L').count(), 0, "{d}"); } - - #[test] - fn nice_max_rounds_up_to_one_two_two_and_a_half_or_five() { - assert_eq!(nice_max(0), 1); - assert_eq!(nice_max(10), 10); - assert_eq!(nice_max(11), 20); - assert_eq!(nice_max(1500), 2000); - assert_eq!(nice_max(2400), 2500); - assert_eq!(nice_max(3_145_728), 5_000_000); - assert_eq!(nice_max(15_000_000_000_000_000_000), u64::MAX); - } } diff --git a/crates/forge-web-app/src/mail/templates.rs b/crates/forge-web-app/src/mail/templates.rs index 17dfe9c..1884057 100644 --- a/crates/forge-web-app/src/mail/templates.rs +++ b/crates/forge-web-app/src/mail/templates.rs @@ -215,12 +215,6 @@ mod tests { assert!(!body.contains(&"x".repeat(COMMENT_LIMIT + 1))); } - #[test] - fn short_comments_are_kept_whole() { - assert_eq!(truncate("héllo", 10), "héllo"); - assert_eq!(truncate("héllo", 2), "hé…"); - } - #[test] fn body_has_the_actor_line_comment_url_and_footer_in_order() { let (_, body) = notification(Lang::En, &sample(Some("Looks good"), "T")); @@ -236,16 +230,6 @@ mod tests { ); } - #[test] - fn turkish_mail_uses_the_turkish_phrases() { - let (_, body) = notification(Lang::Tr, &sample(None, "T")); - assert!(body.starts_with("tahinli yorum yaptı."), "{body}"); - assert!( - body.contains("Bu e-postayı şu nedenle alıyorsunuz:"), - "{body}" - ); - } - #[test] fn a_system_change_reads_as_someone() { let mut ctx = sample(None, "T"); diff --git a/crates/forge-web-app/src/notify.rs b/crates/forge-web-app/src/notify.rs index cbbb5ff..b5c077d 100644 --- a/crates/forge-web-app/src/notify.rs +++ b/crates/forge-web-app/src/notify.rs @@ -1045,15 +1045,4 @@ mod tests { .await; assert!(mail_to(&fx, "bob@test.example").await.is_empty()); } - - #[test] - fn host_of_drops_scheme_port_and_path() { - assert_eq!( - host_of("https://forge.example.com:8443/"), - "forge.example.com" - ); - assert_eq!(host_of("http://127.0.0.1:7660"), "127.0.0.1"); - assert_eq!(host_of("forge.test/x"), "forge.test"); - assert_eq!(host_of("https:///"), "localhost"); - } } diff --git a/crates/forge-web-app/src/views/heatmap.rs b/crates/forge-web-app/src/views/heatmap.rs index 5c2d626..602a0d1 100644 --- a/crates/forge-web-app/src/views/heatmap.rs +++ b/crates/forge-web-app/src/views/heatmap.rs @@ -482,16 +482,6 @@ mod tests { pairs.iter().map(|(d, n)| ((*d).to_owned(), *n)).collect() } - fn day(cal: &Calendar, date: (i64, i64, i64)) -> Day { - cal.weeks - .iter() - .flatten() - .flatten() - .find(|d| d.date == date) - .copied() - .expect("day is in the window") - } - #[test] fn empty_input_gives_an_empty_calendar() { let cal = build(&[], TODAY); @@ -560,18 +550,6 @@ mod tests { assert_eq!(cal.total, 36); } - #[test] - fn levels_follow_the_fixed_buckets() { - assert_eq!( - [0, 1, 3, 4, 7, 8, 12, 13, 500].map(level), - [0, 1, 1, 2, 2, 3, 3, 4, 4] - ); - let cal = build(&counts(&[("2026-10-16", 8), ("2026-10-15", 1)]), TODAY); - assert_eq!(day(&cal, TODAY).level, 3); - assert_eq!(day(&cal, (2026, 10, 15)).level, 1); - assert_eq!(day(&cal, (2026, 10, 14)).level, 0); - } - #[test] fn window_is_53_monday_first_weeks_ending_this_week() { let cal = build(&[], TODAY); @@ -610,14 +588,6 @@ mod tests { assert_eq!(cal.total, 1); } - #[test] - fn month_labels_start_at_the_first_column_holding_the_first() { - let cal = build(&[], TODAY); - assert_eq!(cal.months[0], (2, 11)); - assert!(cal.months.contains(&(50, 10))); - assert_eq!(cal.months.len(), 12); - } - #[test] fn leap_day_is_a_real_date() { let cal = build( diff --git a/crates/forge-web-app/src/views/mod.rs b/crates/forge-web-app/src/views/mod.rs index c9c9918..4fcb40a 100644 --- a/crates/forge-web-app/src/views/mod.rs +++ b/crates/forge-web-app/src/views/mod.rs @@ -1591,12 +1591,6 @@ pub fn ssh_clone_url(config: &Config, owner: &str, name: &str) -> String { mod tests { use super::*; - #[test] - fn enc_keeps_slashes_and_escapes_the_rest() { - assert_eq!(enc("feature/x y#1"), "feature/x%20y%231"); - assert_eq!(enc("a~b.c_d-e"), "a~b.c_d-e"); - } - #[test] fn live_strip_is_one_pill_for_one_run_and_a_summary_for_more() { let run = |state, number| ActorRun { @@ -1706,63 +1700,4 @@ mod tests { assert_eq!(origin_of("https://user:pw@files.test"), None); assert_eq!(csp_for(None), CSP); } - - #[test] - fn iso_time_matches_known_instants() { - assert_eq!(iso_time(0), "1970-01-01T00:00:00Z"); - assert_eq!(iso_time(1_700_000_000), "2023-11-14T22:13:20Z"); - assert_eq!(iso_time(951_782_400), "2000-02-29T00:00:00Z"); - } - - #[test] - fn relative_time_picks_the_unit() { - assert_eq!(relative_time(Lang::En, 100, 110), "just now"); - assert_eq!(relative_time(Lang::En, 0, 120), "2 minutes ago"); - assert_eq!(relative_time(Lang::En, 0, 3_600), "1 hour ago"); - assert_eq!(relative_time(Lang::En, 0, 2 * 86_400), "2 days ago"); - assert_eq!(relative_time(Lang::En, 0, 10), "just now"); - assert_eq!(relative_time(Lang::En, 0, 30 * 86_400), "1 month ago"); - assert_eq!(relative_time(Lang::En, 0, 365 * 86_400), "1 year ago"); - assert_eq!(relative_time(Lang::En, 0, 2 * 365 * 86_400), "2 years ago"); - assert_eq!(relative_time(Lang::Tr, 100, 110), "az önce"); - assert_eq!(relative_time(Lang::Tr, 0, 60), "1 dakika önce"); - assert_eq!(relative_time(Lang::Tr, 0, 5 * 60), "5 dakika önce"); - assert_eq!(relative_time(Lang::Tr, 0, 3 * 3_600), "3 saat önce"); - assert_eq!(relative_time(Lang::Tr, 0, 3 * 86_400), "3 gün önce"); - assert_eq!(relative_time(Lang::Tr, 0, 2 * 2_592_000), "2 ay önce"); - assert_eq!(relative_time(Lang::Tr, 0, 365 * 86_400), "1 yıl önce"); - assert_eq!( - rel_words(Lang::En), - "just now|{n} minute ago|{n} minutes ago|{n} hour ago|{n} hours ago|{n} day ago|\ - {n} days ago|{n} month ago|{n} months ago|{n} year ago|{n} years ago|\ - in {n} minute|in {n} minutes|in {n} hour|in {n} hours|in {n} day|in {n} days|\ - in {n} month|in {n} months|in {n} year|in {n} years" - ); - assert_eq!(rel_words(Lang::Tr).split('|').nth(4), Some("{n} saat önce")); - } - - #[test] - fn short_oid_and_sizes() { - assert_eq!(short_oid("0123456789abcdef"), "0123456"); - assert_eq!(human_size(Lang::En, 12), "12 bytes"); - assert_eq!(human_size(Lang::En, 2048), "2.0 KiB"); - assert_eq!(human_size(Lang::En, 1_572_864), "1.5 MiB"); - assert_eq!(human_size(Lang::Tr, 512), "512 bayt"); - assert_eq!(human_size(Lang::Tr, 2048), "2,0 KiB"); - assert_eq!(human_size(Lang::Tr, 1_572_864), "1,5 MiB"); - } - - #[test] - fn ghost_and_visibility_labels_follow_the_language() { - assert_eq!(i18n::deleted_user(Lang::En), "Deleted user"); - assert_eq!(i18n::deleted_user(Lang::Tr), "Silinmiş kullanıcı"); - assert_eq!( - i18n::visibility_label(Lang::Tr, forge_core::Visibility::Public), - "Herkese açık" - ); - assert_eq!( - i18n::visibility_label(Lang::En, forge_core::Visibility::Private), - "Private" - ); - } } diff --git a/crates/forge-web-app/src/views/repo_list.rs b/crates/forge-web-app/src/views/repo_list.rs index f41f11c..5542cc8 100644 --- a/crates/forge-web-app/src/views/repo_list.rs +++ b/crates/forge-web-app/src/views/repo_list.rs @@ -190,31 +190,3 @@ pub fn pager_links( let next = (page < pages).then(|| href(page + 1)); (links, prev, next) } - -#[cfg(test)] -mod tests { - use super::page_numbers; - - fn shown(page: u64, pages: u64) -> String { - page_numbers(page, pages) - .into_iter() - .map(|n| n.map_or("...".to_owned(), |n| n.to_string())) - .collect::>() - .join(" ") - } - - #[test] - fn pages_are_compact_with_gaps() { - assert_eq!(shown(1, 1), "1"); - assert_eq!(shown(1, 3), "1 2 3"); - assert_eq!(shown(1, 7), "1 2 3 4 5 6 7"); - assert_eq!(shown(5, 12), "1 ... 4 5 6 ... 12"); - assert_eq!(shown(1, 12), "1 2 3 4 5 ... 12"); - assert_eq!(shown(12, 12), "1 ... 8 9 10 11 12"); - assert_eq!(shown(4, 12), "1 2 3 4 5 ... 12"); - assert_eq!(shown(9, 12), "1 ... 8 9 10 11 12"); - for page in 1..=54 { - assert_eq!(page_numbers(page, 54).len(), 7, "page {page}"); - } - } -} diff --git a/crates/forge-web-app/src/views/timeline.rs b/crates/forge-web-app/src/views/timeline.rs index 8c6483b..2a306fa 100644 --- a/crates/forge-web-app/src/views/timeline.rs +++ b/crates/forge-web-app/src/views/timeline.rs @@ -84,17 +84,3 @@ pub async fn history_strip( } }) } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn bar_heights_are_log_scaled_with_a_floor() { - assert_eq!(bar_percent(0, 0), MIN_BAR_PERCENT); - assert_eq!(bar_percent(0, 1000), MIN_BAR_PERCENT); - assert_eq!(bar_percent(1000, 1000), 100); - assert_eq!(bar_percent(31, 999), 50); - assert!(bar_percent(10, 1000) > bar_percent(2, 1000)); - } -}