style: remove redundant code narration
This commit is contained in:
1 parent
495f31778b
commit
783fb76f06
115 files changed
+19
-746
No files matched your search
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// integration tests for the public content-scanner APIs: shaders, worlds,
|
||||
// and resource packs. each scanner walks an instance's minecraft subdir
|
||||
// and returns ContentEntry rows; shape varies slightly per content type
|
||||
// (worlds are directories only, packs and shaders accept .zip or dir, etc.).
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rmcl::instance::content::resource_packs::scan_resource_packs;
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// integration tests for build_launch_invocation - the seam that takes an
|
||||
// instance config plus resolved auth credentials and returns the full java
|
||||
// invocation that would be spawned. these tests build the expected on-disk
|
||||
// fixture layout in a tempdir, call the seam, and assert on the rendered
|
||||
// LaunchInvocation. nothing here actually spawns a process.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use chrono::Utc;
|
||||
@@ -18,8 +12,6 @@ use rmcl::instance::launch::{
|
||||
};
|
||||
use rmcl::instance::models::{InstanceConfig, ModLoader};
|
||||
|
||||
// ---------- helpers ----------
|
||||
|
||||
const PLAYER: &str = "TestPlayer";
|
||||
const PLAYER_UUID: &str = "00000000-0000-0000-0000-000000000001";
|
||||
const PLAYER_TOKEN: &str = "secret-access-token";
|
||||
@@ -86,11 +78,6 @@ fn fake_java(tmp: &TempDir, major: u32) -> String {
|
||||
path.to_string_lossy().into_owned()
|
||||
}
|
||||
|
||||
// builds the on-disk layout that build_launch_invocation expects:
|
||||
// <tmp>/instances/<name>/minecraft/ (instance dir, created empty)
|
||||
// <tmp>/meta/versions/<game_version>/meta.json
|
||||
// <tmp>/meta/cache/loaders/profiles/ (created empty)
|
||||
// <tmp>/meta/libraries/ (created empty)
|
||||
struct Fixture {
|
||||
_tmp: TempDir,
|
||||
instances_dir: PathBuf,
|
||||
@@ -208,8 +195,6 @@ fn platform_classpath_sep() -> &'static str {
|
||||
if cfg!(windows) { ";" } else { ":" }
|
||||
}
|
||||
|
||||
// ---------- vanilla ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn vanilla_modern_builds_complete_invocation() {
|
||||
let fx = Fixture::new("v1", "1.20.1", modern_vanilla_meta("1.20.1"));
|
||||
@@ -247,12 +232,10 @@ async fn vanilla_modern_builds_complete_invocation() {
|
||||
inv.jvm_args
|
||||
);
|
||||
|
||||
// working_dir is <instances_dir>/<name>/minecraft
|
||||
assert_eq!(
|
||||
inv.working_dir,
|
||||
fx.instances_dir.join("v1").join("minecraft")
|
||||
);
|
||||
// classpath = the one vanilla lib + the vanilla client jar
|
||||
let slf4j = fx
|
||||
.meta_dir
|
||||
.join("cache/minecraft/libraries/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar");
|
||||
@@ -339,12 +322,10 @@ async fn vanilla_legacy_args_format_substitutes_tokens() {
|
||||
|
||||
assert_eq!(inv.main_class, "net.minecraft.launchwrapper.Launch");
|
||||
|
||||
// legacy format has no upstream jvm args; jvm_args should be just Xms/Xmx
|
||||
assert_eq!(inv.jvm_args.len(), 2);
|
||||
assert!(inv.jvm_args[0].starts_with("-Xms"));
|
||||
assert!(inv.jvm_args[1].starts_with("-Xmx"));
|
||||
|
||||
// game_args should be space-split with substitutions applied
|
||||
let joined = inv.game_args.join(" ");
|
||||
assert!(joined.contains(&format!("--username {}", PLAYER)));
|
||||
assert!(joined.contains(&format!("--uuid {}", PLAYER_UUID)));
|
||||
@@ -352,8 +333,6 @@ async fn vanilla_legacy_args_format_substitutes_tokens() {
|
||||
assert!(joined.contains("--userType msa"));
|
||||
}
|
||||
|
||||
// ---------- forge ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn forge_modern_includes_add_opens() {
|
||||
let fx = Fixture::new("f1", "1.20.1", modern_vanilla_meta("1.20.1"));
|
||||
@@ -444,7 +423,6 @@ async fn forge_local_lib_dir_preferred_over_meta_dir() {
|
||||
"expected local fmlloader on classpath: {:?}",
|
||||
inv.classpath
|
||||
);
|
||||
// and the meta-dir candidate should not appear
|
||||
let meta_candidate = fx
|
||||
.meta_dir
|
||||
.join("libraries/net/minecraftforge/fmlloader/1.20.1-47.2.0/fmlloader-1.20.1-47.2.0.jar");
|
||||
@@ -454,8 +432,6 @@ async fn forge_local_lib_dir_preferred_over_meta_dir() {
|
||||
);
|
||||
}
|
||||
|
||||
// ---------- fabric ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn fabric_implicit_inheritsfrom_resolves() {
|
||||
let fx = Fixture::new("fab", "1.20.1", modern_vanilla_meta("1.20.1"));
|
||||
@@ -482,7 +458,6 @@ async fn fabric_implicit_inheritsfrom_resolves() {
|
||||
inv.main_class,
|
||||
"net.fabricmc.loader.impl.launch.knot.KnotClient"
|
||||
);
|
||||
// both fabric-loader and vanilla slf4j must appear on the merged classpath
|
||||
let fabric_loader = fx.meta_dir.join(
|
||||
"cache/minecraft/libraries/net/fabricmc/fabric-loader/0.15.0/fabric-loader-0.15.0.jar",
|
||||
);
|
||||
@@ -501,8 +476,6 @@ async fn fabric_implicit_inheritsfrom_resolves() {
|
||||
);
|
||||
}
|
||||
|
||||
// ---------- neoforge ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn neoforge_inheritsfrom_resolves() {
|
||||
let fx = Fixture::new("ne", "1.20.6", modern_vanilla_meta("1.20.6"));
|
||||
@@ -541,8 +514,6 @@ async fn neoforge_inheritsfrom_resolves() {
|
||||
);
|
||||
}
|
||||
|
||||
// ---------- template substitution ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn auth_credentials_substituted_in_game_args() {
|
||||
let fx = Fixture::new("auth", "1.20.1", modern_vanilla_meta("1.20.1"));
|
||||
@@ -576,7 +547,6 @@ async fn auth_credentials_substituted_in_game_args() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn version_type_substituted() {
|
||||
// type = "snapshot" in the fixture; ${version_type} should render that
|
||||
let mut meta = modern_vanilla_meta("1.20.1");
|
||||
meta["type"] = json!("snapshot");
|
||||
let fx = Fixture::new("vt", "1.20.1", meta);
|
||||
@@ -593,8 +563,6 @@ async fn version_type_substituted() {
|
||||
);
|
||||
}
|
||||
|
||||
// ---------- classpath ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn classpath_uses_platform_separator() {
|
||||
let fx = Fixture::new("cp", "1.20.1", modern_vanilla_meta("1.20.1"));
|
||||
@@ -604,7 +572,6 @@ async fn classpath_uses_platform_separator() {
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// with two classpath entries we should see exactly one separator
|
||||
assert_eq!(inv.classpath.len(), 2);
|
||||
let sep = platform_classpath_sep();
|
||||
assert_eq!(inv.classpath_string.matches(sep).count(), 1);
|
||||
@@ -612,7 +579,6 @@ async fn classpath_uses_platform_separator() {
|
||||
|
||||
#[tokio::test]
|
||||
async fn rule_disallow_excludes_library() {
|
||||
// a library whose rule always denies must not appear on the classpath
|
||||
let mut meta = modern_vanilla_meta("1.20.1");
|
||||
meta["libraries"] = json!([
|
||||
{
|
||||
@@ -654,8 +620,6 @@ async fn rule_disallow_excludes_library() {
|
||||
);
|
||||
}
|
||||
|
||||
// ---------- memory ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn xms_xmx_use_config_memory() {
|
||||
let fx = Fixture::new("mem", "1.20.1", modern_vanilla_meta("1.20.1"));
|
||||
@@ -707,7 +671,6 @@ async fn instance_launch_options_are_injected() {
|
||||
async fn default_memory_used_when_unset() {
|
||||
let fx = Fixture::new("memdef", "1.20.1", modern_vanilla_meta("1.20.1"));
|
||||
let config = make_config("memdef", "1.20.1", ModLoader::Vanilla);
|
||||
// memory_min and memory_max default to None in make_config
|
||||
|
||||
let inv = build_launch_invocation(&config, &fx.instances_dir, &fx.meta_dir, &test_auth(), None)
|
||||
.await
|
||||
@@ -717,8 +680,6 @@ async fn default_memory_used_when_unset() {
|
||||
assert!(inv.jvm_args.iter().any(|a| a == "-Xmx2G"));
|
||||
}
|
||||
|
||||
// ---------- error paths ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn meta_not_found_returns_error() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// integration tests for the public log files API.
|
||||
// these tests touch the filesystem and exercise the module as an external
|
||||
// consumer would.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rmcl::instance::logs::files::{create_log_file, log_dir, read_log_file, scan_log_files};
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// integration tests for the loader-specific net::* fetchers (forge,
|
||||
// fabric, quilt, neoforge). each module's fetch_* function now has a
|
||||
// _from variant that lets the test point the HTTP call at a wiremock
|
||||
// server; the production constants stay unchanged.
|
||||
|
||||
use serde_json::json;
|
||||
use wiremock::matchers::{method, path};
|
||||
use wiremock::{Mock, MockServer, ResponseTemplate};
|
||||
@@ -20,8 +15,6 @@ use rmcl::net::quilt::{
|
||||
fetch_quilt_game_versions_from, fetch_quilt_profile_from, fetch_quilt_versions_from,
|
||||
};
|
||||
|
||||
// ---------- forge ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn forge_fetch_versions_filters_by_prefix() {
|
||||
let server = MockServer::start().await;
|
||||
@@ -67,12 +60,9 @@ async fn forge_fetch_game_versions_extracts_unique() {
|
||||
.expect("forge game versions");
|
||||
|
||||
let ids: Vec<&str> = versions.iter().map(|v| v.id.as_str()).collect();
|
||||
// dedup + reverse-sort
|
||||
assert_eq!(ids, vec!["1.20.1", "1.19.4"]);
|
||||
}
|
||||
|
||||
// ---------- fabric ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn fabric_fetch_game_versions_parses_response() {
|
||||
let server = MockServer::start().await;
|
||||
@@ -146,8 +136,6 @@ async fn fabric_fetch_profile_parses_libraries() {
|
||||
assert_eq!(profile.libraries[0].url, "https://maven.fabricmc.net/");
|
||||
}
|
||||
|
||||
// ---------- quilt ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn quilt_fetch_game_versions_parses_response() {
|
||||
let server = MockServer::start().await;
|
||||
@@ -208,8 +196,6 @@ async fn quilt_fetch_profile_parses_libraries() {
|
||||
);
|
||||
}
|
||||
|
||||
// ---------- neoforge ----------
|
||||
|
||||
#[tokio::test]
|
||||
async fn neoforge_fetch_versions_filters_by_prefix() {
|
||||
let server = MockServer::start().await;
|
||||
@@ -292,7 +278,6 @@ async fn neoforge_fetch_game_versions_reverse_engineers_mc_versions() {
|
||||
assert!(ids.contains(&"26.1.1"));
|
||||
assert!(ids.contains(&"1.21"));
|
||||
assert!(ids.contains(&"1.20.4"));
|
||||
// both versions should be marked stable (no snapshot flag in maven)
|
||||
assert!(versions.iter().all(|v| v.stable));
|
||||
}
|
||||
|
||||
@@ -300,7 +285,6 @@ async fn neoforge_fetch_game_versions_reverse_engineers_mc_versions() {
|
||||
async fn neoforge_fetch_versions_rejects_invalid_game_version() {
|
||||
let server = MockServer::start().await;
|
||||
let url = format!("{}/maven-api", server.uri());
|
||||
// no mock - the function should error out before hitting the network
|
||||
let err = fetch_neoforge_versions_from(&HttpClient::new(), &url, "bogus")
|
||||
.await
|
||||
.expect_err("invalid game version");
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// integration tests for the public mojang fetchers. wiremock stands in for
|
||||
// Mojang so tests are fast, deterministic, and don't depend on the live
|
||||
// endpoint. these are different from the #[ignore = "hits live Mojang API"]
|
||||
// tests in tests/live_apis.rs which verify the upstream schema hasn't drifted;
|
||||
// these here verify our parsing + retry envelope on synthetic responses.
|
||||
|
||||
use serde_json::json;
|
||||
use wiremock::matchers::{method, path};
|
||||
use wiremock::{Mock, MockServer, ResponseTemplate};
|
||||
@@ -112,8 +106,6 @@ async fn fetch_version_meta_returns_struct_and_raw_bytes() {
|
||||
assert_eq!(meta.downloads.client.size, 12345);
|
||||
assert_eq!(meta.java_version.unwrap().major_version, 17);
|
||||
|
||||
// the raw bytes must parse back to the same struct - verifies the
|
||||
// get_json_with_raw plumbing actually captures the upstream body intact.
|
||||
let reparsed: serde_json::Value = serde_json::from_slice(&raw).expect("raw is json");
|
||||
assert_eq!(reparsed["id"], "1.20.1");
|
||||
assert_eq!(reparsed["mainClass"], "net.minecraft.client.main.Main");
|
||||
@@ -214,7 +206,6 @@ async fn download_libraries_skips_when_destination_exists() {
|
||||
.await
|
||||
.expect("noop succeeds");
|
||||
|
||||
// file untouched, mock untouched (server drop will panic if it isn't)
|
||||
assert_eq!(std::fs::read(&existing).unwrap(), b"already there");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// integration tests for the retry envelope in src/net/mod.rs. wiremock
|
||||
// stands in for live upstream APIs so we can assert that 5xx responses
|
||||
// retry, 4xx responses fail fast, and the cap (MAX_RETRIES = 3, total
|
||||
// 4 attempts) is honoured. these tests exercise public HttpClient methods,
|
||||
// not the private retry helper directly.
|
||||
//
|
||||
// Tokio time is paused in retrying tests so the production backoff remains
|
||||
// covered without adding wall-clock delay to the suite.
|
||||
|
||||
@@ -32,14 +26,11 @@ fn client_without_timeout() -> HttpClient {
|
||||
reqwest::Client::builder().build().unwrap().into()
|
||||
}
|
||||
|
||||
// ---------- get_json (via get_with_retry) ----------
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn get_json_retries_5xx_then_succeeds() {
|
||||
let server = MockServer::start().await;
|
||||
let attempts = Arc::new(AtomicUsize::new(0));
|
||||
|
||||
// first request: 503. second request: 200.
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/api"))
|
||||
.respond_with(move |_: &wiremock::Request| {
|
||||
@@ -124,8 +115,6 @@ async fn get_bytes_limited_rejects_oversized_responses() {
|
||||
assert!(error.to_string().contains("8-byte limit"));
|
||||
}
|
||||
|
||||
// ---------- download_file ----------
|
||||
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn download_file_retries_5xx_then_succeeds() {
|
||||
let server = MockServer::start().await;
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// SPDX-FileCopyrightText: 2026 Constantin Bauer
|
||||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
|
||||
// integration tests for the public scan_screenshots API.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use rmcl::instance::screenshots::scan_screenshots;
|
||||
|
||||
Reference in new issue
Block a user