diff --git a/src/instance/loader/mod.rs b/src/instance/loader/mod.rs index ab6378f..655b186 100644 --- a/src/instance/loader/mod.rs +++ b/src/instance/loader/mod.rs @@ -181,17 +181,13 @@ mod tests { ); } + // shape-pinning test: a synthetic versionInfo from a 1.7.10 forge + // install_profile.json must deserialise as a LaunchProfile so the + // launch flow's render_args + resolve pipeline can consume it. no + // filesystem round-trip; serde_json directly on the literal bytes. #[test] - fn legacy_forge_version_info_round_trips_through_save_profile_json() { - use tempfile::TempDir; - let tmp = TempDir::new().unwrap(); - let meta_dir = tmp.path().to_path_buf(); - - // synthetic versionInfo shape from a 1.7.10 forge install_profile.json. - // legacy forge uses minecraftArguments (the flat string format) and - // typically omits inheritsFrom (the launch flow's implicit fallback - // handles that). - let version_info = serde_json::json!({ + fn legacy_forge_version_info_deserialises_as_launch_profile() { + let bytes = br#"{ "id": "1.7.10-Forge10.13.4.1614-1.7.10", "mainClass": "net.minecraft.launchwrapper.Launch", "minecraftArguments": "--username ${auth_player_name} --tweakClass cpw.mods.fml.common.launcher.FMLTweaker", @@ -199,35 +195,18 @@ mod tests { { "name": "net.minecraftforge:forge:10.13.4.1614", "url": "http://files.minecraftforge.net/maven/" }, { "name": "net.minecraft:launchwrapper:1.9" } ] - }); + }"#; - // mirror the install path: write versionInfo as compact JSON. - let profiles_dir = meta_dir.join("loader-profiles"); - std::fs::create_dir_all(&profiles_dir).unwrap(); - let serialized = serde_json::to_vec(&version_info).unwrap(); - std::fs::write( - profiles_dir.join("forge-1.7.10-10.13.4.1614.json"), - &serialized, - ) - .unwrap(); - - let saved_bytes = std::fs::read( - meta_dir - .join("loader-profiles") - .join("forge-1.7.10-10.13.4.1614.json"), - ) - .unwrap(); - - // the cached profile must parse as a LaunchProfile so the launch - // flow's render_args + resolve pipeline can consume it. let profile: crate::launch_profile::model::LaunchProfile = - serde_json::from_slice(&saved_bytes).unwrap(); + serde_json::from_slice(bytes).unwrap(); assert_eq!(profile.id, "1.7.10-Forge10.13.4.1614-1.7.10"); assert_eq!( profile.main_class.as_deref(), Some("net.minecraft.launchwrapper.Launch") ); - assert!(profile.inherits_from.is_none()); // launch flow's implicit fallback adds it + // legacy forge profiles omit inheritsFrom; the launch flow's + // implicit fallback adds it before resolve. + assert!(profile.inherits_from.is_none()); assert!( profile .minecraft_arguments @@ -244,21 +223,18 @@ mod tests { profile.libraries[0].url.as_deref(), Some("http://files.minecraftforge.net/maven/") ); - // legacy libs typically have no `downloads.artifact` - they're - // resolved at launch time via maven_coord_to_path(name). + // legacy libs typically have no downloads.artifact; they resolve + // at launch time via maven_coord_to_path(name). assert!(profile.libraries[0].downloads.is_none()); } + // shape-pinning test: a synthetic upstream fabric profile (no + // inheritsFrom, no arguments, libraries with name+url) must + // deserialise as a LaunchProfile so the install path can write it + // through to disk and the launch flow can read it back. #[test] fn raw_fabric_profile_bytes_parse_as_launch_profile() { - use tempfile::TempDir; - let tmp = TempDir::new().unwrap(); - let meta_dir = tmp.path(); - - // a synthetic upstream fabric profile shape (id, mainClass, - // libraries with name+url, no inheritsFrom, no arguments). - // simulates what the install path will write verbatim. - let upstream_bytes = br#"{ + let bytes = br#"{ "id": "fabric-loader-0.14.21-1.20.1", "mainClass": "net.fabricmc.loader.impl.launch.knot.KnotClient", "libraries": [ @@ -267,22 +243,16 @@ mod tests { ] }"#; - let profiles_dir = meta_dir.join("loader-profiles"); - std::fs::create_dir_all(&profiles_dir).unwrap(); - let profile_path = profiles_dir.join("fabric-1.20.1-0.14.21.json"); - std::fs::write(&profile_path, upstream_bytes).unwrap(); - - let saved = std::fs::read(&profile_path).unwrap(); - assert_eq!(saved, upstream_bytes.to_vec()); - let parsed: crate::launch_profile::model::LaunchProfile = - serde_json::from_slice(&saved).unwrap(); + serde_json::from_slice(bytes).unwrap(); assert_eq!(parsed.id, "fabric-loader-0.14.21-1.20.1"); assert_eq!( parsed.main_class.as_deref(), Some("net.fabricmc.loader.impl.launch.knot.KnotClient") ); - assert!(parsed.inherits_from.is_none()); // launch flow's implicit fallback handles it + // upstream Fabric profiles omit inheritsFrom; the launch flow's + // implicit fallback handles it before resolve. + assert!(parsed.inherits_from.is_none()); assert!(parsed.arguments.is_none()); assert_eq!(parsed.libraries.len(), 2); assert_eq!( diff --git a/src/tui/error_buffer.rs b/src/tui/error_buffer.rs index ab8d0f9..84c03dd 100644 --- a/src/tui/error_buffer.rs +++ b/src/tui/error_buffer.rs @@ -89,12 +89,6 @@ mod tests { } } - #[test] - fn has_errors_after_push() { - push_error(make_event("err_has")); - assert!(has_errors()); - } - #[test] fn peek_does_not_remove() { push_error(make_event("err_peek"));