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.
This commit is contained in:
1 parent
0eb47fd7b4
commit
5f43128a80
8 files changed
+351
-6
No files matched your search
@@ -355,4 +355,39 @@ mod tests {
|
||||
.unwrap();
|
||||
insta::assert_snapshot!(terminal.backend());
|
||||
}
|
||||
|
||||
// Confirm step with loader_version=None: covers the branch where the
|
||||
// pack didn't declare a loader version (rare upstream, but happens for
|
||||
// older mmc packs). render_confirm_step has to handle the Option.
|
||||
#[test]
|
||||
fn import_modpack_renders_confirm_step_without_loader_version() {
|
||||
use crate::instance::import::{ImportSummary, PackFormat};
|
||||
use crate::instance::models::ModLoader;
|
||||
use std::path::PathBuf;
|
||||
|
||||
let _serial = TEST_SERIAL.lock().unwrap_or_else(|e| e.into_inner());
|
||||
{
|
||||
let mut guard = IMPORT_STATE.lock().expect("IMPORT_STATE lock");
|
||||
*guard = ImportWizardState::default();
|
||||
guard.step = ImportStep::Confirm;
|
||||
guard.summary = Some(ImportSummary {
|
||||
name: "Vanilla Pack".into(),
|
||||
pack_version: "2.0".into(),
|
||||
game_version: "1.20.1".into(),
|
||||
loader: ModLoader::Vanilla,
|
||||
loader_version: None,
|
||||
mod_count: 0,
|
||||
override_count: 12,
|
||||
format: PackFormat::Mmc,
|
||||
archive_path: PathBuf::from("/tmp/vanilla.zip"),
|
||||
});
|
||||
}
|
||||
|
||||
let backend = TestBackend::new(60, 14);
|
||||
let mut terminal = Terminal::new(backend).unwrap();
|
||||
terminal
|
||||
.draw(|f| render(f, f.area(), FocusedArea::ImportPopup))
|
||||
.unwrap();
|
||||
insta::assert_snapshot!(terminal.backend());
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: src/tui/widgets/popups/import_modpack/render.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
"╭Import Modpack────────────────────────────────────────────╮"
|
||||
"│Name: Vanilla Pack │"
|
||||
"│Pack Version: 2.0 │"
|
||||
"│MC Version: 1.20.1 │"
|
||||
"│Loader: Vanilla │"
|
||||
"│Mods: 0 files │"
|
||||
"│Overrides: 12 files │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"╰──────────────────────────────────[h] back [Enter] import╯"
|
||||
Reference in new issue
Block a user