added: tests for retry envelope, manager rename, mod precedence, time buckets
Audit identified six high-priority coverage gaps. This commit closes them with 30 net new passing tests. - tests/net_retry.rs (new): 5 wiremock-based tests for the retry envelope in net/mod.rs. Covers get_json + download_file across: 5xx retry-then-succeed, 4xx fail-fast (asserted via wiremock expect(1) so any retry attempt fails the test), and exhaust at MAX_RETRIES = 3 (asserted via expect(4)). The exhaust test takes ~3.5s of wall time because the production code sleeps 500 + 1000 + 2000 ms between attempts; this is unavoidable without making the delays configurable. - tests/launch_pipeline.rs: 3 new error-path tests against build_launch_invocation. merged_profile_missing_main_class_fails surfaces the LaunchError::Parse branch when meta.json deserialises cleanly but lacks mainClass. legacy_loader_profile_missing_loader_version_errors and legacy_loader_profile_missing_installer_json_errors exercise the two Parse branches inside migrate_legacy_loader_profile_if_needed. - instance/manager.rs: 6 tests for rename (happy path, noop on same name, empty target rejected, missing source, target collision) and touch_last_played (sets the field to a stamp within 5 seconds of now). The InstanceManager rename surface had no coverage before; mutating the validation order or the std::fs::rename target would not have failed any existing test. - instance/content/mods.rs: 4 new precedence-chain tests. The reader chain is fabric > quilt > forge-toml (which itself tries neoforge.mods.toml before mods.toml) > mcmod.info. Only the fabric-over-forge precedence had a test before. Adds quilt > forge, forge_toml > mcmod_info, neoforge.mods.toml > mods.toml, and a test that a mods.toml carrying only logoFile (no [[mods]] array) still resolves the icon. - tui/widgets/instances.rs: 12 new tests for format_last_played. One case for the None input (returns "Never played"), then an rstest covering each bucket boundary in the match (0/59 just-now, 60/3599 minutes, 3600/86399 hours, 86400/2591999 days, 2592000/31535999 months, >=31536000 over-a-year). A mutation that bumps any boundary by one second, or swaps a unit suffix, fails at least one case.
This commit is contained in:
1 parent
7a9dfa850d
commit
623acd9e2c
5 files changed
+438
No files matched your search
@@ -700,6 +700,88 @@ description = "A neoforge mod"
|
||||
assert_eq!(mods[0].name, "Fabric Name");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scan_mods_prefers_quilt_over_forge() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let dir = setup_mods_dir(tmp.path(), "inst");
|
||||
let quilt = r#"{"quilt_loader":{"id":"x","version":"1","metadata":{"name":"Quilt Name","description":"quilt desc"}}}"#;
|
||||
let forge = "[[mods]]\ndisplayName = \"Forge Name\"\ndescription = \"forge desc\"\n";
|
||||
make_jar(
|
||||
&dir,
|
||||
"quilt-over-forge.jar",
|
||||
&[
|
||||
("quilt.mod.json", quilt.as_bytes()),
|
||||
("META-INF/mods.toml", forge.as_bytes()),
|
||||
],
|
||||
);
|
||||
let mods = scan_mods(tmp.path(), "inst");
|
||||
assert_eq!(mods[0].name, "Quilt Name");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scan_mods_prefers_forge_toml_over_mcmod_info() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let dir = setup_mods_dir(tmp.path(), "inst");
|
||||
let forge = "[[mods]]\ndisplayName = \"Forge Name\"\ndescription = \"forge desc\"\n";
|
||||
let mcmod = r#"[{"modid":"legacy","name":"Legacy Name","description":"legacy desc"}]"#;
|
||||
make_jar(
|
||||
&dir,
|
||||
"forge-over-legacy.jar",
|
||||
&[
|
||||
("META-INF/mods.toml", forge.as_bytes()),
|
||||
("mcmod.info", mcmod.as_bytes()),
|
||||
],
|
||||
);
|
||||
let mods = scan_mods(tmp.path(), "inst");
|
||||
assert_eq!(mods[0].name, "Forge Name");
|
||||
}
|
||||
|
||||
// when both neoforge.mods.toml and mods.toml exist in the same jar (the
|
||||
// shape a dual-format mod might ship), the neoforge one wins because
|
||||
// read_forge_toml_meta tries it first via .or_else.
|
||||
#[test]
|
||||
fn scan_mods_prefers_neoforge_toml_over_forge_toml() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let dir = setup_mods_dir(tmp.path(), "inst");
|
||||
let neoforge = "[[mods]]\ndisplayName = \"NeoForge Name\"\ndescription = \"neoforge desc\"\n";
|
||||
let forge = "[[mods]]\ndisplayName = \"Forge Name\"\ndescription = \"forge desc\"\n";
|
||||
make_jar(
|
||||
&dir,
|
||||
"neoforge-over-forge.jar",
|
||||
&[
|
||||
("META-INF/neoforge.mods.toml", neoforge.as_bytes()),
|
||||
("META-INF/mods.toml", forge.as_bytes()),
|
||||
],
|
||||
);
|
||||
let mods = scan_mods(tmp.path(), "inst");
|
||||
assert_eq!(mods[0].name, "NeoForge Name");
|
||||
}
|
||||
|
||||
// a mods.toml with logoFile but no [[mods]] array (e.g. a dependency-only
|
||||
// library jar) should still surface as a scanned mod with empty name +
|
||||
// description but with the icon resolved.
|
||||
#[test]
|
||||
fn scan_mods_reads_mods_toml_without_mods_array() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let dir = setup_mods_dir(tmp.path(), "inst");
|
||||
let mods_toml = "logoFile = \"icon.png\"\n";
|
||||
let png_bytes = b"\x89PNG fake icon";
|
||||
make_jar(
|
||||
&dir,
|
||||
"lib-only.jar",
|
||||
&[
|
||||
("META-INF/mods.toml", mods_toml.as_bytes()),
|
||||
("icon.png", png_bytes),
|
||||
],
|
||||
);
|
||||
let mods = scan_mods(tmp.path(), "inst");
|
||||
assert_eq!(mods.len(), 1);
|
||||
// metadata name is empty, so scan_one_mod falls back to the file stem
|
||||
assert_eq!(mods[0].name, "lib-only");
|
||||
// the icon path from logoFile must resolve to the in-jar entry
|
||||
assert_eq!(mods[0].icon_bytes.as_deref(), Some(png_bytes.as_slice()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scan_mods_fallback_icon_paths() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
Reference in new issue
Block a user