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.
This commit is contained in:
objz committed 2026-05-27 17:22:32 +02:00
1 parent 1f1a0ebb3d
commit 6ac9f4e239
2 files changed
+152 -1

No files matched your search

+11 -1
View File
@@ -110,7 +110,17 @@ pub struct AssetObject {
}
pub async fn fetch_version_manifest(client: &HttpClient) -> Result<VersionManifest, NetError> {
client.get_json(MANIFEST_URL).await
fetch_version_manifest_from(client, MANIFEST_URL).await
}
// same as fetch_version_manifest but lets the caller pick the URL. exists so
// integration tests can point at a wiremock server; production callers go
// through fetch_version_manifest with the upstream Mojang URL.
pub async fn fetch_version_manifest_from(
client: &HttpClient,
url: &str,
) -> Result<VersionManifest, NetError> {
client.get_json(url).await
}
// fetches and parses a version's metadata. also returns the raw response