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.
This commit is contained in:
1 parent
d612f83446
commit
0d1b7984fc
8 files changed
+431
-1
No files matched your search
@@ -279,4 +279,80 @@ mod tests {
|
||||
.unwrap();
|
||||
insta::assert_snapshot!(terminal.backend());
|
||||
}
|
||||
|
||||
// Version step: pre-populate versions as LoadState::Loaded with synthetic
|
||||
// VersionInfo entries so render walks the list path without triggering
|
||||
// any network helpers.
|
||||
#[test]
|
||||
fn import_modpack_renders_version_step() {
|
||||
use crate::net::modrinth::VersionInfo;
|
||||
|
||||
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::Version;
|
||||
guard.project_title = Some("Synthetic Pack".into());
|
||||
guard.versions = LoadState::Loaded(vec![
|
||||
VersionInfo {
|
||||
id: "v1".into(),
|
||||
name: "1.0.0".into(),
|
||||
version_number: "1.0.0".into(),
|
||||
game_versions: vec!["1.20.1".into()],
|
||||
loaders: vec!["fabric".into()],
|
||||
files: vec![],
|
||||
},
|
||||
VersionInfo {
|
||||
id: "v2".into(),
|
||||
name: "0.9.0".into(),
|
||||
version_number: "0.9.0".into(),
|
||||
game_versions: vec!["1.20.1".into()],
|
||||
loaders: vec!["fabric".into()],
|
||||
files: vec![],
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
// Confirm step: needs a populated ImportSummary so the render path
|
||||
// doesn't bail. ImportSummary is constructed manually with synthetic
|
||||
// values; archive_path is a fake tempdir-ish path that never gets read.
|
||||
#[test]
|
||||
fn import_modpack_renders_confirm_step() {
|
||||
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: "Synthetic Pack".into(),
|
||||
pack_version: "1.0.0".into(),
|
||||
game_version: "1.20.1".into(),
|
||||
loader: ModLoader::Fabric,
|
||||
loader_version: Some("0.15.0".into()),
|
||||
mod_count: 42,
|
||||
override_count: 3,
|
||||
format: PackFormat::Mrpack,
|
||||
archive_path: PathBuf::from("/tmp/synthetic.mrpack"),
|
||||
});
|
||||
}
|
||||
|
||||
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: Synthetic Pack │"
|
||||
"│Pack Version: 1.0.0 │"
|
||||
"│MC Version: 1.20.1 │"
|
||||
"│Loader: Fabric 0.15.0 │"
|
||||
"│Mods: 42 files │"
|
||||
"│Overrides: 3 files │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"╰──────────────────────────────────[h] back [Enter] import╯"
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
---
|
||||
source: src/tui/widgets/popups/import_modpack/render.rs
|
||||
expression: terminal.backend()
|
||||
---
|
||||
"╭Import Modpack────────────────────────────────────────────╮"
|
||||
"│▶ 1.0.0 1.20.1 fabric │"
|
||||
"│ 0.9.0 1.20.1 fabric │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"│ │"
|
||||
"╰──────────────────────[/] search [h] back [Enter] select╯"
|
||||
Reference in new issue
Block a user