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.
This commit is contained in:
objz committed 2026-05-27 18:03:57 +02:00
1 parent 0d1b7984fc
commit 0eb47fd7b4
6 files changed
+266 -8

No files matched your search

+10 -1
View File
@@ -36,6 +36,15 @@ fn game_version_to_neoforge_prefix(game_version: &str) -> Option<String> {
pub async fn fetch_neoforge_versions(
client: &HttpClient,
game_version: &str,
) -> Result<Vec<String>, NetError> {
fetch_neoforge_versions_from(client, NEOFORGE_API_BASE, game_version).await
}
// same as fetch_neoforge_versions but lets tests point at a wiremock server.
pub async fn fetch_neoforge_versions_from(
client: &HttpClient,
api_url: &str,
game_version: &str,
) -> Result<Vec<String>, NetError> {
let prefix = match game_version_to_neoforge_prefix(game_version) {
Some(p) => p,
@@ -47,7 +56,7 @@ pub async fn fetch_neoforge_versions(
}
};
let maven_versions: NeoForgeMavenVersions = client.get_json(NEOFORGE_API_BASE).await?;
let maven_versions: NeoForgeMavenVersions = client.get_json(api_url).await?;
let versions: Vec<String> = maven_versions
.versions