Addresses the six items the last review flagged. Four are polish for
existing tests; two add coverage for previously-untested public APIs.
Polish:
- instance/content/mods.rs: icon_path_from_value_map now asserts a
single deterministic value. serde_json::Map is a BTreeMap so the
"128" key sorts before "64" and the test no longer needs an
order-tolerant disjunction.
- cli/log.rs: replace the hand-rolled unique_temp_dir with
tempfile::tempdir() across both tests. Drop the trailing
remove_dir_all cleanup since TempDir handles that on Drop. Last
inline test file using the hand-rolled pattern.
- running.rs: remove drain_empty_returns_empty. Two consecutive calls
to drain_last_played in the same test can race with the parallel
push_and_drain_last_played test which pushes to the same global
LAST_PLAYED state. drain semantics are covered by the existing
push_and_drain test.
- tui/error_buffer.rs: peek_does_not_remove now actually verifies the
invariant the name promises. Pushes a tagged event, captures the
count before and after peek_error, asserts the count is unchanged
and the tagged event is still in the queue. Previous version only
asserted that something was returned.
New coverage:
- net/neoforge.rs: added fetch_neoforge_game_versions_from(client,
api_url) mirroring the existing _from pattern. tests/net_loaders.rs
gains neoforge_fetch_game_versions_reverse_engineers_mc_versions
covering the maven-version-to-MC-version reverse mapping, which was
only touched by the #[ignore] live API test before.
- instance/import/mod.rs: six new tests for detect_format covering
mrpack detection, mmc-pack at root and nested, the priority case
where both markers are present, unknown archives, and missing
files. Helper make_pack_zip builds in-memory zips so the tests
don't need fixture files on disk.
Closes the seven remaining tractable coverage gaps the final review
flagged. All tests-only or tiny *_from variants matching the existing
pattern. 18 new tests.
- src/instance/launch/patches.rs: seven inline tests for the lwjgl3ify
patch helpers that were entirely untested before. strip_replaced_libs
has happy + no-op cases. parse_add_opens covers the basic Add-Opens
extraction, the MANIFEST.MF continuation-line case (the tricky one:
jar manifests wrap lines with a trailing space + leading-space marker
that gets stripped on join), missing manifest, and missing file.
add_lwjgl3 verifies that only jars that actually exist in lib_dir
end up on the classpath.
- src/net/forge.rs: three inline tests for has_legacy_install_profile.
Builds synthetic forge installer zips in a tempdir with and without
the versionInfo key in install_profile.json; covers the missing-jar
branch with a path that doesn't exist.
- src/net/modrinth.rs: five-case rstest for url_encode covering the
unreserved set, space, RFC 3986 reserved characters, multi-byte UTF-8
(the encoder operates per-byte so emoji exercises the multi-byte
path), and empty input.
- src/net/fabric.rs / src/net/quilt.rs: added fetch_*_profile_from and
fetch_*_profile_with_raw_from variants mirroring the existing pattern.
Existing fetch_*_profile and *_with_raw delegate to them with the
upstream constants.
- tests/net_loaders.rs: two new wiremock tests (fabric_fetch_profile
parses libraries, quilt_fetch_profile parses libraries) using the
new _from variants.
- src/tui/widgets/popups/import_modpack/render.rs: extra snapshot for
the Confirm step when loader_version is None (vanilla pack or old
mmc pack). The previous Confirm snapshot covered Some(_) only.
Production touches stay minimal: the four new pub fn delegators in
fabric.rs and quilt.rs, all behaviour-preserving.
Same pattern as fetch_version_manifest_from from the earlier batch:
each fetcher gets a sibling that takes the URL as a parameter; the
existing function delegates to it with the upstream constant.
Production callers are unchanged.
- src/net/forge.rs: fetch_forge_versions_from(client, promotions_url,
game_version) and fetch_forge_game_versions_from(client,
promotions_url).
- src/net/fabric.rs: fetch_fabric_game_versions_from(client, base) and
fetch_fabric_versions_from(client, base, game_version). The fabric
API is hierarchical so the helpers take the meta base URL and append
the rest internally, matching the existing layout.
- src/net/quilt.rs: same pair as fabric.
- src/net/neoforge.rs: fetch_neoforge_versions_from(client, api_url,
game_version).
- src/net/mojang.rs: download_assets_from(client, meta, meta_dir,
assets_base) so tests can route per-asset CDN downloads through a
wiremock server. download_assets delegates to it with
ASSETS_BASE_URL.
tests/net_loaders.rs adds eight wiremock tests covering each new
fetcher and a happy + error case for neoforge's invalid-game-version
branch. tests/net_mojang.rs gains download_assets_from_writes_index_and_assets
which now exercises the full per-asset download path against synthetic
hashes.
Production touches are minimal (one new pub fn delegating to the
existing one for each fetcher). Behaviour of existing callers is
unchanged.
The existing fetch_version_manifest hard-codes the Mojang URL, so tests
either had to hit the live endpoint (the #[ignore] live-API test) or
not run at all. Adds fetch_version_manifest_from(client, url) that lets
callers pick the URL; fetch_version_manifest stays compatible by
delegating with the upstream constant. fetch_version_meta_with_raw
already takes the URL via VersionEntry, no change needed.
tests/net_mojang.rs adds three wiremock tests:
- fetch_version_manifest_parses_synthetic_response verifies the
VersionManifest deserialiser against a synthetic upstream-shaped
payload (latest + versions list).
- fetch_version_meta_returns_struct_and_raw_bytes verifies both the
parsed VersionMeta and the raw byte capture path used by the install
flow to write upstream JSON byte-for-byte.
- fetch_version_manifest_retries_5xx_and_succeeds confirms the retry
envelope integrates correctly with VersionManifest deserialisation
on top of the retry-only tests in tests/net_retry.rs.
These don't replace the #[ignore = "hits live Mojang API"] canary
which still runs on master push to detect upstream schema drift.
Audit found 9 confirmed-weak unit tests plus several newly-found ones that
asserted things equivalent to themselves, returned vacuous truth, or had
assertions guarded behind conditionals that silently swallowed failure.
Changes by file:
- auth/accounts.rs: create_offline_account_fields now pins the uuid to
offline_uuid("TestPlayer") instead of !is_empty(); mutating the uuid
derivation would fail this now.
- cli/mod.rs: parses_instance_list_subcommand drills into the list
subcommand under instance rather than only verifying the instance
group exists.
- config/theme.rs: border_style_roundtrip is now an rstest covering all
four BorderStyle variants; mutating any non-Double arm is caught.
- instance/desktop.rs: removed desktop_path_returns_some (assertion was
gated behind if let Some so could pass when the function returned
None); build_content_linux* already covers the real behaviour.
- instance/launch/mod.rs: removed five predicate-only tests that
asserted serde defaulting on LaunchProfile rather than invoking the
migration predicate. Added two tests that actually call
migrate_legacy_meta_if_needed (rstest over modern/legacy arg shapes)
and migrate_legacy_loader_profile_if_needed (modern-with-inheritsFrom
early-return). Renamed build_game_args_renders_upstream_arguments,
dropping the misleading "and appends loader args" clause that the
test never covered.
- instance/loader/mod.rs: removed test_vanilla_install_noop (no
assertion at all) and test_vanilla_get_versions (asserted a hardcoded
Ok(vec!["vanilla"]) return). Replaced test_vanilla_factory with an
rstest covering all five ModLoader variants; a misordered match arm
in get_installer is caught.
- migrate.rs: removed cleanup_instance_leftovers_handles_missing_dir
(had no assertions and was redundant with
cleanup_instance_leftovers_removes_shim_and_log4j).
- net/mod.rs: removed detect_java_falls_back_to_java which asserted
!is_empty() against a function whose worst-case fallback is the
literal string "java"; structurally uncatchable.
- tui/error_buffer.rs: peek_all_returns_newest_first and
auto_assigned_ids_are_unique now tag their pushed events with a
unique substring and filter peek_all_errors to just those, so the
assertions actually fire instead of being silently skipped via
if all.len() >= 2 when shared static state interfered.
Total: net zero change in test count (deletions and parameterised
replacements roughly balance), but mutation coverage of the surviving
suite is materially stronger.
- drop stale phase planning comments from launch_profile module headers.
- simplify merge_libraries to HashSet<&str> (no string clones).
- rewrite coord_key with match_indices (clearer intent).
- read /proc/sys/kernel/osrelease on linux for mojang_os_version
instead of shelling out to uname; return empty elsewhere.
- add comment explaining why is_retryable excludes Parse.
- shorten the launch_profile::... paths in launch/mod.rs with top-level
use statements.
- derive Default on LaunchProfile + nested types so test fixtures use
..Default::default() instead of listing every None field.
- inline account_can_launch at its single call site, delete the helper
and three tests that exercised trivially-correct one-line logic.
- extract get_json_with_raw on HttpClient and save_profile_bytes in
instance::loader; collapses three near-identical fetch_X_profile_with_raw
helpers and three near-identical 'create dir + write bytes' blocks.
several smaller fixes from the code review:
- add os_version to RuleContext + OsCondition for mojang rules that
constrain natives selection by host version (rare, but in the spec).
- factor mojang_os_name/arch/version into a shared launch_profile::system
module instead of duplicating between net/mojang.rs and launch/mod.rs.
- get_json and get_bytes now retry transient failures (5xx, connect,
body decode) via a shared get_with_retry envelope; previously only
download_file had retry logic.
- migrate_legacy_meta_if_needed falls back to the stale cached profile
with a warn log on network failure instead of erroring out (offline
launches now work).
- tightened legacy-loader detection by requiring the unique-to-rmcl
gameArguments field; clearer error when loader_version is absent.
- forge legacy versionInfo write uses compact serialization (no
pretty-print key reorder).
- deleted dead fetch_version_meta and save_profile_json.
- documented quick-play templates omission in templates::lookup.
- added end-to-end test that loads a vanilla profile from disk, loads a
loader profile with inheritsFrom, resolves, renders, and snapshots.
stop re-serializing FabricProfile/QuiltProfile through narrow structs;
new fetch_X_profile_with_raw helpers return both the parsed shape (for
library downloads) and the upstream bytes (written byte-for-byte to the
loader-profiles cache). also fixes a latent issue surfaced by the
change: the legacy-loader migration predicate now skips Fabric and Quilt
explicitly since their upstream shape matches the predicate but they
have no installer JSON to recover from.
install_forge_from_profile now writes the upstream versionInfo as compact
JSON (no key reordering, no field stripping) instead of building a custom
{mainClass, libraries, gameArguments} shape. legacy 1.7.10-era Forge
profiles ride the same LaunchProfile + resolve + render pipeline as
modern Forge. drops the no-longer-needed extract_extra_game_args helper.
vanilla launches now read upstream mojang JSON via the new LaunchProfile
path, render game/JVM args through launch_profile::render with template
substitution, and store the cached meta.json byte-for-byte instead of
re-serializing through a narrow struct. legacy stripped meta.json files
are re-fetched on first launch. adds HttpClient::get_bytes and
fetch_version_meta_with_raw; collapses the two library-rule evaluators
into one shared launch_profile::rules::evaluate.
Renames Cargo package, binary, internal path identifiers, java shim,
user-agent, log filename, desktop shortcut Exec lines, and CLI program
name. Wires src/migrate.rs into main() so existing users have their
on-disk data (~/.config/mcl/, ~/.local/share/mcl/, ~/.cache/mcl/) moved
to the new locations on first launch.
BREAKING CHANGE: binary is now named rmcl. Old paths are auto-migrated.
old forge installers don't have --installClient, so we extract the
universal jar and library info directly from install_profile.json
inside the installer jar. also tries multiple maven URL formats since
forge naming is inconsistent across versions.
split import.rs into import/ module with mod.rs, mrpack.rs, mmc.rs.
auto-detects pack format from zip contents (modrinth.index.json or
mmc-pack.json). moved input parsing from net/modrinth.rs to the
import module since it handles routing for all formats now.