From d632c473203e0e244be2c494bf4f0f569101325a Mon Sep 17 00:00:00 2001 From: Julian Chang Date: Mon, 28 Sep 2026 11:13:41 -0400 Subject: [PATCH] remove unnecessary tests (#881) --- packages/oneclient_app/src/ipc.rs | 6 -- packages/oneclient_app/src/protocol/mod.rs | 9 --- .../oneclient_app/src/view/onboarding/mod.rs | 10 ---- .../oneclient_content/src/bundles/install.rs | 1 - .../src/packages/file_identity.rs | 23 +------- .../oneclient_content/tests/file_identity.rs | 26 +-------- .../oneclient_core/src/migration/vanilla.rs | 56 +++---------------- packages/oneclient_core/src/relocate.rs | 14 ----- .../oneclient_core/tests/download_verify.rs | 19 +------ packages/oneclient_core/tests/providers.rs | 9 --- packages/oneclient_java/src/locate.rs | 10 ---- packages/oneclient_java/src/platform.rs | 7 --- packages/oneclient_mc/src/arguments.rs | 11 ---- packages/oneclient_mc/src/install.rs | 6 +- 14 files changed, 14 insertions(+), 193 deletions(-) diff --git a/packages/oneclient_app/src/ipc.rs b/packages/oneclient_app/src/ipc.rs index 11772cf8..c59bf3e7 100644 --- a/packages/oneclient_app/src/ipc.rs +++ b/packages/oneclient_app/src/ipc.rs @@ -315,12 +315,6 @@ pub use imp::Listener; mod tests { use super::*; - #[test] - fn a_launch_request_survives_the_wire() { - let command = IpcCommand::Launch("fabric-1-20".into()); - assert_eq!(IpcCommand::decode(&command.encode()), Some(command)); - } - #[test] fn focus_survives_the_wire() { assert_eq!( diff --git a/packages/oneclient_app/src/protocol/mod.rs b/packages/oneclient_app/src/protocol/mod.rs index 59415824..af366e1a 100644 --- a/packages/oneclient_app/src/protocol/mod.rs +++ b/packages/oneclient_app/src/protocol/mod.rs @@ -69,15 +69,6 @@ pub fn is_registered() -> bool { mod tests { use super::*; - #[test] - fn a_folder_survives_the_round_trip() { - let folder = "26.1.2 Fabric"; - assert_eq!( - parse_launch_url(&launch_url(folder)).as_deref(), - Some(folder) - ); - } - #[test] fn a_space_is_encoded_rather_than_left_to_split_the_url() { assert!(launch_url("My Pack").ends_with("/My%20Pack")); diff --git a/packages/oneclient_app/src/view/onboarding/mod.rs b/packages/oneclient_app/src/view/onboarding/mod.rs index 8cb1ec22..7473df77 100644 --- a/packages/oneclient_app/src/view/onboarding/mod.rs +++ b/packages/oneclient_app/src/view/onboarding/mod.rs @@ -421,14 +421,4 @@ mod tests { } } } - - #[test] - fn a_run_without_the_folder_step_is_numbered_as_it_always_was() { - assert_eq!(onboarding_total(false, false), 7); - assert_eq!(onboarding_total(true, false), 8); - assert_eq!( - onboarding_step_index(&Route::OnboardingTerms {}, false, false), - 1 - ); - } } diff --git a/packages/oneclient_content/src/bundles/install.rs b/packages/oneclient_content/src/bundles/install.rs index 8b645808..8ad10c99 100644 --- a/packages/oneclient_content/src/bundles/install.rs +++ b/packages/oneclient_content/src/bundles/install.rs @@ -836,7 +836,6 @@ mod tests { #[test] fn unknown_override_string_is_ignored() { assert_eq!(OverrideType::parse("something-new"), None); - assert!(!effective_enabled(&file(false), None)); } fn row(bundle: &str, pid: &str, ty: OverrideType) -> ClusterBundleOverrideRow { diff --git a/packages/oneclient_content/src/packages/file_identity.rs b/packages/oneclient_content/src/packages/file_identity.rs index cdf50cec..e277c2c8 100644 --- a/packages/oneclient_content/src/packages/file_identity.rs +++ b/packages/oneclient_content/src/packages/file_identity.rs @@ -1,7 +1,4 @@ -use std::path::Path; - -use crate::error::ContentResult; -use polyio::{normalize_hash, sha1_bytes}; +use polyio::normalize_hash; #[derive(Debug, Clone, PartialEq, Eq)] pub struct FileIdentity { @@ -10,30 +7,12 @@ pub struct FileIdentity { } impl FileIdentity { - pub fn from_bytes(bytes: &[u8]) -> Self { - Self { - sha1: sha1_bytes(bytes), - cf_fingerprint: Some(curseforge_fingerprint(bytes)), - } - } - - #[tracing::instrument(level = "debug", skip(path))] - pub async fn from_path(path: impl AsRef) -> ContentResult { - let bytes = polyio::read(path).await?; - Ok(Self::from_bytes(&bytes)) - } - pub fn from_sha1(sha1: impl AsRef) -> Self { Self { sha1: normalize_hash(sha1.as_ref()), cf_fingerprint: None, } } - - pub fn with_curseforge_fingerprint(mut self, fingerprint: u32) -> Self { - self.cf_fingerprint = Some(fingerprint); - self - } } pub fn curseforge_fingerprint(bytes: &[u8]) -> u32 { diff --git a/packages/oneclient_content/tests/file_identity.rs b/packages/oneclient_content/tests/file_identity.rs index 0e9bfb08..8c6e6d83 100644 --- a/packages/oneclient_content/tests/file_identity.rs +++ b/packages/oneclient_content/tests/file_identity.rs @@ -1,4 +1,4 @@ -use oneclient_content::packages::{FileIdentity, curseforge_fingerprint}; +use oneclient_content::packages::curseforge_fingerprint; #[test] fn curseforge_fingerprint_ignores_padding_whitespace() { @@ -7,33 +7,9 @@ fn curseforge_fingerprint_ignores_padding_whitespace() { assert_eq!(a, b); } -#[test] -fn curseforge_fingerprint_empty_is_stable() { - assert_eq!(curseforge_fingerprint(&[]), curseforge_fingerprint(&[])); -} - #[test] fn curseforge_fingerprint_differs_for_content() { let a = curseforge_fingerprint(b"hello"); let b = curseforge_fingerprint(b"world"); assert_ne!(a, b); } - -#[test] -fn file_identity_from_bytes_sets_sha1_and_cf_fingerprint() { - let id = FileIdentity::from_bytes(b"test jar content"); - assert_eq!(id.sha1.len(), 40); - assert!(id.cf_fingerprint.is_some()); -} - -#[test] -fn file_identity_from_sha1_has_no_cf_fingerprint() { - let id = FileIdentity::from_sha1("a".repeat(40)); - assert!(id.cf_fingerprint.is_none()); -} - -#[test] -fn file_identity_with_fingerprint_roundtrip() { - let id = FileIdentity::from_sha1("abc").with_curseforge_fingerprint(12345); - assert_eq!(id.cf_fingerprint, Some(12345)); -} diff --git a/packages/oneclient_core/src/migration/vanilla.rs b/packages/oneclient_core/src/migration/vanilla.rs index fcb8fc72..be4478f0 100644 --- a/packages/oneclient_core/src/migration/vanilla.rs +++ b/packages/oneclient_core/src/migration/vanilla.rs @@ -129,54 +129,6 @@ pub async fn import_game_dir( mod tests { use super::*; - fn excluded(name: &str) -> bool { - IMPORT_EXCLUDE_TOP - .iter() - .any(|e| e.eq_ignore_ascii_case(name)) - } - - #[test] - fn excludes_package_and_launcher_managed_dirs() { - for name in [ - "mods", - "resourcepacks", - "shaderpacks", - "datapacks", - "versions", - "libraries", - "assets", - "logs", - ] { - assert!(excluded(name), "{name} should be excluded"); - } - } - - #[test] - fn excludes_mojang_credentials() { - assert!(excluded("launcher_accounts.json")); - assert!(excluded("launcher_msa_credentials.bin")); - } - - #[test] - fn excludes_third_party_launcher_data() { - for name in ["cheatbreaker_accounts.json", "feather-mods", "jre"] { - assert!(excluded(name), "{name} should be excluded"); - } - } - - #[test] - fn keeps_user_data() { - for name in [ - "saves", - "config", - "options.txt", - "screenshots", - "servers.dat", - ] { - assert!(!excluded(name), "{name} must not be excluded"); - } - } - #[tokio::test] async fn import_copies_user_data_and_skips_the_rest() { let src = polyio::tempdir().await.expect("src dir"); @@ -188,6 +140,7 @@ mod tests { "servers.dat", "launcher_accounts.json", "launcher_msa_credentials.bin", + "cheatbreaker_accounts.json", ] { polyio::write(src.join(file), b"x".to_vec()).await.unwrap(); } @@ -198,6 +151,9 @@ mod tests { ("mods", "sodium.jar"), ("resourcepacks", "faithful.zip"), ("shaderpacks", "bsl.zip"), + ("datapacks", "pack.zip"), + ("feather-mods", "mod.jar"), + ("jre", "bin/java"), ("versions", "1.21.1/1.21.1.jar"), ("libraries", "com/foo/foo.jar"), ("assets", "objects/ab/abcdef"), @@ -227,12 +183,16 @@ mod tests { "mods", "resourcepacks", "shaderpacks", + "datapacks", "versions", "libraries", "assets", "logs", "launcher_accounts.json", "launcher_msa_credentials.bin", + "cheatbreaker_accounts.json", + "feather-mods", + "jre", ] { assert!( !dst.join(skipped).exists(), diff --git a/packages/oneclient_core/src/relocate.rs b/packages/oneclient_core/src/relocate.rs index de323224..d12303a4 100644 --- a/packages/oneclient_core/src/relocate.rs +++ b/packages/oneclient_core/src/relocate.rs @@ -722,20 +722,6 @@ async fn remove_children_except(dir: &Path, keep: &[OsString]) -> Result<(), Str mod tests { use super::*; - #[test] - fn a_managed_runtime_sits_under_the_prefix_the_swap_looks_for() { - let root = PathBuf::from("D:").join("OneClient"); - let prefix = java_root(&root); - - let runtime = paths::java_dir() - .map(|dir| dir.join("21").join("bin").join("java")) - .expect("java dir resolves"); - - let managed = root.join("metadata").join("java").join("21"); - assert!(managed.to_string_lossy().starts_with(&prefix)); - assert!(runtime.to_string_lossy().contains("java")); - } - #[test] fn the_write_ahead_sidecars_are_never_copied_by_hand() { let names = database_names(); diff --git a/packages/oneclient_core/tests/download_verify.rs b/packages/oneclient_core/tests/download_verify.rs index 6d762017..ba27115a 100644 --- a/packages/oneclient_core/tests/download_verify.rs +++ b/packages/oneclient_core/tests/download_verify.rs @@ -2,7 +2,7 @@ use oneclient_core::dev; use oneclient_core::game::download_to_path; use oneclient_events::{GroupedProgressSession, TaskCategory}; use polyio::testing::ScratchDir as Scratch; -use polyio::{Sha1Stream, sha1_bytes, sha1_file}; +use polyio::{sha1_bytes, sha1_file}; /// Minecraft asset objects are content-addressed and immutable so this /// URL/hash pair stays valid @@ -11,23 +11,6 @@ const ASSET_URL: &str = "https://resources.download.minecraft.net/af/af96f55a90eaf11b327f1b5f8834a051027dc506"; const ASSET_SIZE: u64 = 2063; -#[test] -fn sha1_stream_matches_one_shot_hash() { - let data: Vec = (0..70_000u32).map(|i| (i % 251) as u8).collect(); - - let mut hasher = Sha1Stream::new(); - for chunk in data.chunks(4096) { - hasher.update(chunk); - } - - assert_eq!(hasher.finish(), sha1_bytes(&data)); -} - -#[test] -fn sha1_stream_of_empty_input_matches() { - assert_eq!(Sha1Stream::new().finish(), sha1_bytes(&[])); -} - #[tokio::test] async fn sha1_file_matches_sha1_bytes() { let dir = Scratch::new("sha1-file"); diff --git a/packages/oneclient_core/tests/providers.rs b/packages/oneclient_core/tests/providers.rs index b5d98484..d05845de 100644 --- a/packages/oneclient_core/tests/providers.rs +++ b/packages/oneclient_core/tests/providers.rs @@ -14,15 +14,6 @@ fn registry_get_unknown_provider_errors() { assert!(err.to_string().contains("not registered")); } -#[tokio::test] -async fn registry_providers_match_ids() { - let registry = oneclient_content::packages::PackageProviderRegistry::new(); - - for id in registry.remote_ids() { - assert_eq!(registry.get(id).unwrap().id(), id); - } -} - #[tokio::test] #[ignore = "requires network"] async fn modrinth_search_returns_hits() { diff --git a/packages/oneclient_java/src/locate.rs b/packages/oneclient_java/src/locate.rs index 88341500..2d937d62 100644 --- a/packages/oneclient_java/src/locate.rs +++ b/packages/oneclient_java/src/locate.rs @@ -236,16 +236,6 @@ mod tests { .collect() } - #[test] - fn a_kit_outranks_a_runtime_even_when_it_is_older() { - let ranking = ranked(vec![ - candidate("/jre-21", "21.0.9", false), - candidate("/jdk-21", "21.0.1", true), - ]); - - assert_eq!(ranking, vec!["/jdk-21", "/jre-21"]); - } - #[test] fn patch_levels_are_compared_as_numbers() { let ranking = ranked(vec![ diff --git a/packages/oneclient_java/src/platform.rs b/packages/oneclient_java/src/platform.rs index 3b13b1f7..3d09500e 100644 --- a/packages/oneclient_java/src/platform.rs +++ b/packages/oneclient_java/src/platform.rs @@ -234,11 +234,4 @@ mod tests { }; assert_eq!(HostTarget::CURRENT.archive(), expected); } - - #[test] - fn musl_is_only_ever_reported_on_linux() { - if HostTarget::CURRENT.is_musl() { - assert!(matches!(HostTarget::CURRENT.os, HostOs::Linux { .. })); - } - } } diff --git a/packages/oneclient_mc/src/arguments.rs b/packages/oneclient_mc/src/arguments.rs index c4a53ac5..610f2823 100644 --- a/packages/oneclient_mc/src/arguments.rs +++ b/packages/oneclient_mc/src/arguments.rs @@ -773,17 +773,6 @@ mod tests { ); } - #[test] - fn every_tier_starts_small_and_grows_into_the_memory_setting() { - for major in [8, 17, 21, 25] { - assert_eq!( - flags(major, "amd64", 8192).first().unwrap(), - "-Xms512M", - "java {major} should not commit the ceiling up front" - ); - } - } - #[test] fn a_tiny_profile_never_starts_above_its_ceiling() { assert_eq!( diff --git a/packages/oneclient_mc/src/install.rs b/packages/oneclient_mc/src/install.rs index 30beeae6..b2e8d10f 100644 --- a/packages/oneclient_mc/src/install.rs +++ b/packages/oneclient_mc/src/install.rs @@ -1567,10 +1567,10 @@ mod tests { } #[test] - fn a_deleted_assets_directory_asks_for_a_repair() { - let dir = scratch("assets-deleted"); + fn a_deleted_objects_directory_asks_for_a_repair() { + let dir = scratch("assets-no-objects"); let (index, objects) = install_assets(&dir); - std::fs::remove_dir_all(dir.join("assets")).unwrap(); + std::fs::remove_dir_all(&objects).unwrap(); assert!(assets_tree_missing(&index, &objects));