remove unnecessary tests (#881)
This commit is contained in:
parent
5f7b624d82
commit
d632c47320
14 changed files with 14 additions and 193 deletions
|
|
@ -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!(
|
||||
|
|
|
|||
|
|
@ -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"));
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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<Path>) -> ContentResult<Self> {
|
||||
let bytes = polyio::read(path).await?;
|
||||
Ok(Self::from_bytes(&bytes))
|
||||
}
|
||||
|
||||
pub fn from_sha1(sha1: impl AsRef<str>) -> 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 {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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<u8> = (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");
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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![
|
||||
|
|
|
|||
|
|
@ -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 { .. }));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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!(
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue