From 458e219424527dee24d8b8d314daeb7870dfe340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 2 Dec 2026 05:45:39 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A5=20remove:=20redundant=20core,=20ci?= =?UTF-8?q?=20and=20runner=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/forge-ci/src/config.rs | 6 --- crates/forge-ci/src/proto.rs | 6 --- crates/forge-ci/src/size.rs | 8 ---- crates/forge-core/src/config.rs | 38 ------------------- crates/forge-core/src/lfs_token.rs | 16 -------- crates/forge-core/src/names.rs | 9 ----- crates/forge-core/src/raw_token.rs | 9 ----- crates/forge-core/src/store/health.rs | 17 --------- crates/forge-core/src/store/mod.rs | 27 ------------- crates/forge-core/src/tz.rs | 30 --------------- .../tests/integration/store_basic.rs | 32 ---------------- crates/forge-runner/src/sandbox/idmap.rs | 32 ---------------- 12 files changed, 230 deletions(-) diff --git a/crates/forge-ci/src/config.rs b/crates/forge-ci/src/config.rs index a7ad3ec..7e9d458 100644 --- a/crates/forge-ci/src/config.rs +++ b/crates/forge-ci/src/config.rs @@ -458,10 +458,4 @@ artifacts = ["target/release/forge"] .unwrap(); assert_eq!(flat.job_order(), vec!["a", "b", "c"]); } - - #[test] - fn example_order() { - let cfg = parse_config(EXAMPLE).unwrap(); - assert_eq!(cfg.job_order(), vec!["test", "lint"]); - } } diff --git a/crates/forge-ci/src/proto.rs b/crates/forge-ci/src/proto.rs index 55464dc..ec4fa11 100644 --- a/crates/forge-ci/src/proto.rs +++ b/crates/forge-ci/src/proto.rs @@ -239,12 +239,6 @@ pub enum Outcome { mod tests { use super::*; - #[test] - fn outcome_is_snake_case() { - let json = serde_json::to_string(&Outcome::Cancelled).unwrap(); - assert_eq!(json, "\"cancelled\""); - } - #[test] fn old_and_new_claim_and_heartbeat_bodies_parse() { let old: ClaimRequest = serde_json::from_str(r#"{"labels":["linux"]}"#).unwrap(); diff --git a/crates/forge-ci/src/size.rs b/crates/forge-ci/src/size.rs index 2f1340f..cf1a939 100644 --- a/crates/forge-ci/src/size.rs +++ b/crates/forge-ci/src/size.rs @@ -79,12 +79,4 @@ mod tests { assert_eq!(parse_size(bad), None, "{bad:?}"); } } - - #[test] - fn formats_round_trip() { - assert_eq!(format_size(4 << 30), "4g"); - assert_eq!(format_size(1536 << 20), "1536m"); - assert_eq!(format_size(1000), "1000"); - assert_eq!(parse_size(&format_size(3 << 29)), Some(3 << 29)); - } } diff --git a/crates/forge-core/src/config.rs b/crates/forge-core/src/config.rs index 1041878..f8e27bb 100644 --- a/crates/forge-core/src/config.rs +++ b/crates/forge-core/src/config.rs @@ -825,44 +825,6 @@ mod tests { ); } - #[test] - fn optional_sections_default_to_disabled() { - let dir = tempfile::tempdir().unwrap(); - let path = dir.path().join("forge.toml"); - std::fs::write(&path, DEV_DEFAULTS).unwrap(); - let cfg = Config::load(&path).unwrap(); - assert!(!cfg.backup.enabled(), "backup enabled"); - assert_eq!(cfg.backup.interval_hours, 24, "backup interval"); - assert_eq!(cfg.backup.keep, 7, "backup keep"); - assert_eq!(cfg.backup.fsck_interval_days, 7, "backup fsck"); - assert!(cfg.backup.healthcheck_url.is_empty(), "backup healthcheck"); - assert!(!cfg.replication.enabled(), "replication enabled"); - assert_eq!(cfg.replication.ssh_port, 22, "replication ssh port"); - assert_eq!( - cfg.replication.db_snapshot_minutes, 15, - "replication snapshot" - ); - assert_eq!( - cfg.replication.reconcile_minutes, 60, - "replication reconcile" - ); - assert!( - cfg.replication.healthcheck_url.is_empty(), - "replication healthcheck" - ); - assert!(!cfg.self_update.enabled, "self_update enabled"); - assert_eq!(cfg.self_update.branch, "main", "self_update branch"); - assert_eq!(cfg.self_update.job, "build", "self_update job"); - assert_eq!( - cfg.self_update.artifact, "forge-{target}", - "self_update artifact" - ); - assert_eq!(cfg.storage.backend, StorageBackend::Fs, "storage backend"); - assert!(cfg.storage.s3.bucket.is_empty(), "s3 bucket"); - assert!(!cfg.storage.s3.allow_http, "s3 allow_http"); - assert!(!cfg.storage.s3.virtual_hosted_style, "s3 virtual hosted"); - } - #[test] fn replication_target_requires_keys_and_positive_intervals() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/forge-core/src/lfs_token.rs b/crates/forge-core/src/lfs_token.rs index b8b5715..ec39fd6 100644 --- a/crates/forge-core/src/lfs_token.rs +++ b/crates/forge-core/src/lfs_token.rs @@ -64,7 +64,6 @@ pub fn verify(key: &[u8; 32], token: &str, repo_id: &str, wanted: LfsOp, now_uni #[cfg(test)] mod tests { use super::*; - use crate::signed_token::MAC_LEN; const KEY: [u8; 32] = [7; 32]; const OTHER_KEY: [u8; 32] = [9; 32]; @@ -80,21 +79,6 @@ mod tests { assert!(verify(&KEY, &any, "repo-1", LfsOp::Any, NOW)); } - #[test] - fn token_has_expected_shape() { - let token = issue(&KEY, "repo-1", LfsOp::Upload, NOW + 60); - let mut parts = token.splitn(3, '.'); - assert_eq!(parts.next().unwrap(), (NOW + 60).to_string()); - assert_eq!(parts.next().unwrap(), "upload"); - assert_eq!( - BASE64_URL_SAFE_NO_PAD - .decode(parts.next().unwrap()) - .unwrap() - .len(), - MAC_LEN - ); - } - #[test] fn expired_is_rejected() { let token = issue(&KEY, "repo-1", LfsOp::Any, NOW); diff --git a/crates/forge-core/src/names.rs b/crates/forge-core/src/names.rs index 6ac5862..0aecd1b 100644 --- a/crates/forge-core/src/names.rs +++ b/crates/forge-core/src/names.rs @@ -180,13 +180,4 @@ mod tests { ); } } - - #[test] - fn reserved_list_contains_route_names() { - for r in [ - "api", "admin", "register", "explore", "orgs", "about", "git", - ] { - assert!(RESERVED.contains(&r)); - } - } } diff --git a/crates/forge-core/src/raw_token.rs b/crates/forge-core/src/raw_token.rs index f2ae32e..be65f0f 100644 --- a/crates/forge-core/src/raw_token.rs +++ b/crates/forge-core/src/raw_token.rs @@ -30,7 +30,6 @@ pub fn verify_raw(key: &[u8; 32], token: &str, repo_id: &str, now_unix: i64) -> #[cfg(test)] mod tests { use super::*; - use crate::signed_token::MAC_LEN; const KEY: [u8; 32] = [7; 32]; const OTHER_KEY: [u8; 32] = [9; 32]; @@ -42,14 +41,6 @@ mod tests { assert!(verify_raw(&KEY, &token, "repo-1", NOW)); } - #[test] - fn token_has_expected_shape() { - let token = sign_raw(&KEY, "repo-1", NOW + 60); - let (expires, mac) = token.split_once('.').unwrap(); - assert_eq!(expires, (NOW + 60).to_string()); - assert_eq!(BASE64_URL_SAFE_NO_PAD.decode(mac).unwrap().len(), MAC_LEN); - } - #[test] fn expired_is_rejected() { let token = sign_raw(&KEY, "repo-1", NOW); diff --git a/crates/forge-core/src/store/health.rs b/crates/forge-core/src/store/health.rs index 09e88b1..2f7bdd9 100644 --- a/crates/forge-core/src/store/health.rs +++ b/crates/forge-core/src/store/health.rs @@ -57,20 +57,3 @@ impl Store { }) } } - -#[cfg(test)] -mod tests { - use super::*; - - #[tokio::test] - async fn counts_a_fresh_store() { - let dir = tempfile::tempdir().unwrap(); - let store = Store::open(&dir.path().join("f.db")).await.unwrap(); - store.create_user("tahinli", None, "h", true).await.unwrap(); - let c = store.health_counts().await.unwrap(); - assert_eq!( - (c.repos, c.users, c.queued_jobs, c.runners_online), - (0, 1, 0, 0) - ); - } -} diff --git a/crates/forge-core/src/store/mod.rs b/crates/forge-core/src/store/mod.rs index bc21208..5dbaf42 100644 --- a/crates/forge-core/src/store/mod.rs +++ b/crates/forge-core/src/store/mod.rs @@ -1779,33 +1779,6 @@ mod tests { assert_eq!(still.timezone, "Europe/Istanbul"); } - #[test] - fn display_name_validation() { - assert_eq!(validate_display_name(" ").unwrap(), None); - assert_eq!(validate_display_name("").unwrap(), None); - assert_eq!( - validate_display_name(" Ahmet Kaan Gümüş ").unwrap(), - Some("Ahmet Kaan Gümüş".to_string()) - ); - assert!(validate_display_name(&"ğ".repeat(MAX_DISPLAY_NAME_CHARS)).is_ok()); - assert!(matches!( - validate_display_name(&"ğ".repeat(MAX_DISPLAY_NAME_CHARS + 1)), - Err(Error::Invalid(_)) - )); - assert!(matches!( - validate_display_name("two\nlines"), - Err(Error::Invalid(_)) - )); - assert!(matches!( - validate_display_name("tab\there"), - Err(Error::Invalid(_)) - )); - assert!(matches!( - validate_display_name("nul\0byte"), - Err(Error::Invalid(_)) - )); - } - #[tokio::test] async fn display_name_round_trips_and_validates() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/forge-core/src/tz.rs b/crates/forge-core/src/tz.rs index 21d63f0..2cbf9c6 100644 --- a/crates/forge-core/src/tz.rs +++ b/crates/forge-core/src/tz.rs @@ -69,33 +69,3 @@ pub fn local_time_now(tz: &str, now_unix: i64) -> String { .strftime("%H:%M (UTC%:z)") .to_string() } - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn formats_absolute_time_in_zone() { - let unix = 1_792_062_300; - assert_eq!( - format_in_tz(unix, "Europe/Istanbul"), - "2026-10-15 14:05 +03" - ); - assert_eq!(format_in_tz(unix, "Mars/Base"), "2026-10-15 11:05 +00"); - } - - #[test] - fn local_time_shows_offset() { - let unix = 1_792_062_300; - assert_eq!(local_time_now("Europe/Istanbul", unix), "14:05 (UTC+03:00)"); - assert_eq!(local_time_now("UTC", unix), "11:05 (UTC+00:00)"); - } - - #[test] - fn lists_timezones_sorted() { - let zones = all_timezones(); - assert!(zones.iter().any(|z| z == "UTC")); - assert!(zones.iter().any(|z| z == "America/New_York")); - assert!(zones.windows(2).all(|w| w[0] < w[1])); - } -} diff --git a/crates/forge-core/tests/integration/store_basic.rs b/crates/forge-core/tests/integration/store_basic.rs index 040f967..178ee63 100644 --- a/crates/forge-core/tests/integration/store_basic.rs +++ b/crates/forge-core/tests/integration/store_basic.rs @@ -38,38 +38,6 @@ async fn create_user_and_lookup_case_insensitively() { assert_eq!(store.list_users().await.unwrap().len(), 1); } -#[tokio::test] -async fn username_keeps_display_case_and_lookup_folds() { - let dir = tempfile::tempdir().unwrap(); - let store = open_store(&db_path(&dir)).await; - - let created = store - .create_user("Tahinli", None, "h", false) - .await - .unwrap(); - assert_eq!(created.username, "Tahinli"); - - for input in ["tahinli", "TAHINLI", "Tahinli"] { - let found = store - .user_by_username(input) - .await - .unwrap() - .unwrap_or_else(|| panic!("lookup {input:?} should find the user")); - assert_eq!(found.id, created.id); - assert_eq!(found.username, "Tahinli"); - } - - let err = store - .create_user("tahinli", None, "h", false) - .await - .unwrap_err(); - assert!( - matches!(err, Error::Conflict(_)), - "expected Conflict, got {err:?}" - ); - assert_eq!(store.user_count().await.unwrap(), 1); -} - #[tokio::test] async fn duplicate_username_is_conflict_case_insensitive() { let dir = tempfile::tempdir().unwrap(); diff --git a/crates/forge-runner/src/sandbox/idmap.rs b/crates/forge-runner/src/sandbox/idmap.rs index d5fe174..151561b 100644 --- a/crates/forge-runner/src/sandbox/idmap.rs +++ b/crates/forge-runner/src/sandbox/idmap.rs @@ -530,31 +530,6 @@ mod tests { assert_eq!(pick_range(&[]), None); } - #[test] - fn size_and_describe() { - let single = IdMap { - uid: 1000, - gid: 1000, - sub: None, - }; - assert!(!single.is_subuid()); - assert_eq!(single.size(), 1); - assert_eq!(single.describe(), "single uid 1000"); - - let sub = IdMap { - uid: 1000, - gid: 1000, - sub: Some(SubRange { - uid_start: 524288, - gid_start: 524288, - count: 65536, - }), - }; - assert!(sub.is_subuid()); - assert_eq!(sub.size(), 65537); - assert_eq!(sub.describe(), "subuid 524288+65536"); - } - fn os(args: &[&str]) -> Vec { args.iter().map(OsString::from).collect() } @@ -594,13 +569,6 @@ mod tests { } } - #[test] - fn default_is_single() { - let map = IdMap::default(); - assert_eq!(map, IdMap::single()); - assert!(!map.is_subuid()); - } - #[test] fn auto_resolves_to_subuid_on_this_host() { if !map_auto_works() {