Commit Graph
38 Commits
Author SHA1 Message Date
objz 7e7e5c0c31 refactor: share loader library downloads and validate settings 2026-10-01 14:21:27 +02:00
objz 783fb76f06 style: remove redundant code narration 2026-10-01 13:53:12 +02:00
objz 902b0e9347 feat(discovery): add directional provider sorting controls 2026-09-24 20:27:57 +02:00
objz a7ace33ae1 feat(discovery): cache responsive filtered results and provider icons 2026-09-24 20:11:34 +02:00
objz 8c7bbb9a79 feat(content): refine discovery and installed sorting filters 2026-09-24 18:25:47 +02:00
objz 53a95c6022 feat(discovery): add sorting side panel 2026-09-24 14:37:35 +02:00
objz 53191bc23b feat: expand launcher settings 2026-09-04 20:57:07 +02:00
objz 8de0cbaa09 feat: add instance launch settings 2026-09-04 20:06:22 +02:00
objz e1cce7b5b3 fixed fmt 2026-08-24 19:17:37 +02:00
objz 4803fe9e3f feat(net): fetch native libraries and verify mojang downloads
Model natives/classifiers/extract on Library, download the matching
native classifier jar and unpack it into versions/<id>/natives so
pre-1.13 versions can launch. Cached client jar, libraries and assets
are now checked against their recorded size and sha1 instead of a bare
exists(), and fresh client jar downloads are verified before use.
2026-08-24 19:14:09 +02:00
objz 29ad70fa16 chore: add SPDX copyright headers 2026-08-24 19:13:43 +02:00
objz 062a9234ee fix(content): complete provider hardening 2026-08-04 21:41:06 +02:00
objz 695ba5a758 feat(modpacks): check discovered pack updates 2026-08-04 21:32:25 +02:00
objz d488954548 fix(content): bound remote resource usage 2026-08-04 21:02:35 +02:00
objz ea7478eb27 feat(worlds): add metadata cards and quick launch 2026-08-01 16:47:33 +02:00
objz feeb3e6d50 refactor: use canonical module paths 2026-07-27 11:32:15 +02:00
objz 15d76c18a0 refactor: clarify content and tui ownership 2026-07-27 11:03:46 +02:00
objz dc13746841 test(net): make retry and loader coverage deterministic 2026-07-27 01:10:04 +02:00
objz 9b17ec96c5 test(net): consolidate live API smoke tests 2026-07-27 00:38:03 +02:00
objz e21f68fd7c test: harden migration and UI coverage 2026-07-27 00:37:48 +02:00
objz 6f0825c321 test: remove redundant coverage 2026-07-26 23:57:28 +02:00
objz 868f3e5b9d fixed windows test pipeline 2026-07-26 22:13:28 +02:00
objz fbf8142ea0 feat(content): add managed content metadata layout 2026-07-25 12:14:30 +02:00
objz 69549b7152 feat(config-sync): add per-instance config profiles 2026-07-10 16:09:47 +02:00
objz 3dd384c5c6 fixed clippy fail on windows caused by dead code that is only needed on unix 2026-06-16 14:01:32 +02:00
objz 1fd1b4e09d fix(launch): validate required Java version before launch 2026-06-16 12:32:37 +02:00
objz a58e6fb76d style: apply rustfmt 2026-06-16 09:58:34 +02:00
objz c6c774b1e3 refactored: final review polish and detect_format + neoforge coverage
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.
2026-05-27 18:55:19 +02:00
objz 5f43128a80 added: tests for patches helpers, forge installer detection, url_encode, profile fetchers
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.
2026-05-27 18:19:26 +02:00
objz 0eb47fd7b4 added: *_from variants in net::{forge,fabric,quilt,neoforge} + assets
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.
2026-05-27 18:03:57 +02:00
objz 0d1b7984fc added: deferred tests-only items (extra wizard snapshots + library/asset downloads)
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.
2026-05-27 18:03:57 +02:00
objz 6ac9f4e239 added: net::mojang wiremock tests via *_from URL variants
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.
2026-05-27 17:22:32 +02:00
objz 1f1a0ebb3d refactored: test style cleanup + mmc archive extract test
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.
2026-05-27 17:09:09 +02:00
objz 623acd9e2c 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.
2026-05-27 16:44:05 +02:00
objz d2e08d818b added: launch-pipeline integration tests via build_launch_invocation seam
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.
2026-05-26 21:38:17 +02:00
objz cc0dde106a refactored: move public-API filesystem tests to tests/
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).
2026-05-26 21:11:38 +02:00
objz 05bea59ef1 refactored: narrow lib.rs visibility + drop speculative tests/common 2026-05-26 21:00:06 +02:00
objz aeeef26614 added: lib.rs split + tests/ scaffold for integration testing 2026-05-26 20:59:59 +02:00