refactored: address final review punch list

Final-review pass flagged three items. All addressed:

- src/instance/loader/mod.rs: rename and rewrite the two profile-shape
  tests so the test name matches what the body does.

  legacy_forge_version_info_round_trips_through_save_profile_json was
  misleading; the body never called save_installer_profile, it only
  wrote bytes to disk and read them back. Renamed to
  legacy_forge_version_info_deserialises_as_launch_profile and dropped
  the filesystem dance - the test was only ever verifying serde shape
  on the literal byte string.

  raw_fabric_profile_bytes_parse_as_launch_profile got the same
  treatment for consistency: dropped the TempDir + write + read round
  trip since the test only checks deserialisation.

- src/tui/error_buffer.rs: removed has_errors_after_push. The test
  read global state populated by other tests in the same module, so
  it would still pass if push_error were a no-op. The push semantics
  are properly covered by peek_all_returns_newest_first and
  overflow_drops_oldest, both of which use unique tagged messages to
  isolate from cross-test interference.
This commit is contained in:
objz committed 2026-05-27 17:42:14 +02:00
1 parent 8d7a0903fd
commit d612f83446
2 files changed
+22 -58

No files matched your search

+22 -52
View File
@@ -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!(
-6
View File
@@ -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"));