Closes the "zero production touches" subset of the deferred coverage
items the audit had flagged.
- src/tui/widgets/popups/new_instance/render.rs: three new snapshots
for the Version, LoaderVersion, and Confirm steps. Each pre-populates
WIZARD_STATE so ensure_versions_loaded and ensure_loader_versions_loaded
short-circuit on LoadState::Loaded and never spawn a network task. The
TEST_SERIAL mutex established in the earlier batch serialises against
the existing Name/Loader snapshots.
- src/tui/widgets/popups/import_modpack/render.rs: two new snapshots
for the Version step (synthetic VersionInfo entries) and the Confirm
step (synthetic ImportSummary). Same serialisation pattern.
- tests/net_mojang.rs: three new wiremock tests.
download_libraries_writes_artifact_to_meta_dir constructs a synthetic
VersionMeta whose single library points at the wiremock server, then
asserts the bytes land at meta_dir/libraries/<artifact.path>.
download_libraries_skips_when_destination_exists verifies the cache
hit path via wiremock's expect(0).
download_assets_writes_index_when_objects_is_empty exercises the
index fetch+write code path with an empty objects map so the per-asset
download loop never fires.
Zero production touches. download_libraries already takes a
VersionMeta whose libraries carry their own URLs; download_assets'
index fetch reads from meta.asset_index.url (also configurable
per-call), so the empty-objects path doesn't need ASSETS_BASE_URL
overridable. Full per-asset coverage lands in a separate commit.
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.
Picks up the style audit's findings without touching production
behaviour (except for two em-dash characters in non-test code that
violated the no-em-dash rule).
- cli/import.rs, instance/import/mmc.rs: replace the two em-dashes
that leaked into source (one in a user-facing format string, one
in a code comment) with hyphen / colon.
- instance/manager.rs: rewrite test_manager to return TempDir instead
of a hand-rolled tempdir path with manual cleanup. Drop the
trailing std::fs::remove_dir_all from every test. Rename test_*
functions to describe the scenario per CONTRIBUTING (delete_missing_
instance_returns_not_found, save_then_load_all_round_trips_config,
load_one_missing_returns_not_found, etc.).
- migrate.rs: replace unique_tmp + atomic counter with
tempfile::tempdir() across all seven tests; ~10 lines of plumbing
gone, automatic cleanup via Drop.
- auth/accounts.rs: drop the dummy_account wrapper that just forwarded
to create_offline_account; inline the real call at the eight use
sites.
- instance/models.rs: rename test_instance_config_roundtrip to
instance_config_roundtrips_through_json.
- instance/content/mods.rs: drop the "what" comments above straight
forward asserts; keep the one "why" comment that explains an
empty-name + present-logo coverage gap. Trim the obvious "helper to
create a jar (zip) file" comment above make_jar.
- tests/smoke.rs: //! to // for the file header; project convention is
// for files (//! is for crate-level rustdoc, which doesn't render
for integration test crates).
Adds one new test:
- instance/import/mmc.rs: extract_mmc_archive_copies_minecraft_subtree
builds an in-memory zip with a Pack/ prefix, a Pack/mmc-pack.json
sibling, and Pack/.minecraft/{options.txt, mods/test-mod.jar},
then asserts only the .minecraft/ subtree lands in the destination
with relative paths preserved. Closes the mmc extract coverage gap
the audit flagged.
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.
Phase D of the test overhaul. Extracts a build_launch_invocation seam
from launch() so the full launch pipeline (profile loading, inheritsFrom
resolution, classpath assembly, template rendering) can be exercised
without spawning a real java process or hitting the auth servers.
The seam takes resolved auth credentials (LaunchAuth) and returns a
LaunchInvocation struct with the final java path, jvm args, classpath,
main class, extra args, game args, and working dir. launch() shrinks to
a thin wrapper that resolves auth from the account store, calls the
seam, and spawns the process.
tests/launch_pipeline.rs adds 14 integration tests covering: vanilla
modern args; vanilla legacy minecraftArguments; Forge with --add-opens;
Forge local-libs preference; Fabric implicit inheritsFrom resolution;
NeoForge inheritsFrom; auth credential substitution into game args;
version_type substitution; platform classpath separator; rule-disallowed
library exclusion; Xms/Xmx from config; default memory fallback; missing
meta.json error; missing loader profile error.
Per Phase C of the test overhaul: tests that touch the filesystem and
exercise the public API surface (scan_screenshots, scan_shaders,
scan_worlds, scan_resource_packs, log_files) move from inline mod tests
into tests/. They now consume rmcl as an external crate, mirroring how
real callers would.
AccountStore::store_save_and_reload stays inline because the helper it
needs (constructing AccountStore directly with a tempdir path) requires
reaching into a private field; exposing that just for tests would leak
implementation detail. The other accounts tests are in-memory and stay
inline regardless.
The extract_description_* tests in resource_packs stay inline since
they are pure logic on serde_json::Value (no filesystem).
image is added to dev-dependencies so integration tests can fabricate
1x1 PNG fixtures (already a regular dep of the lib).