Skip to content

Commit a0bf9ac

Browse files
committed
test(pkg): cover system-module seeding, live and offline
The offline test pins which modules count as absent; the network-gated one (cargo test seed_live -- --ignored) runs the real fetch, download, checksum and enable against a throwaway config, which is the closest thing to a first apply that does not restart the user's client.
1 parent d8c192c commit a0bf9ac

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

  • rust/crates/spicetify/src/commands

rust/crates/spicetify/src/commands/pkg.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,39 @@ mod tests {
237237
assert!(resolve_version(&module("", &[])).is_err());
238238
}
239239

240+
// Network-gated smoke test for the real seeding path: fetch the registry,
241+
// download each system module, verify its checksum, and enable it into a
242+
// throwaway config. Run with `cargo test -p spicetify --ignored seed_live`.
243+
#[test]
244+
#[ignore = "hits the live registry and downloads artifacts"]
245+
fn seed_live_installs_and_enables_system_modules() {
246+
let root =
247+
std::env::temp_dir().join(format!("spicetify-seed-live-{}", std::process::id()));
248+
let _ = std::fs::remove_dir_all(&root);
249+
std::fs::create_dir_all(&root).expect("temp config");
250+
251+
let vault = fetch_vault(DEFAULT_VAULT).expect("registry reachable");
252+
let ctx = AppContext::from_config(root.clone(), &crate::context::Config::default())
253+
.expect("context");
254+
for id in SYSTEM_MODULES {
255+
let result = seed_system_module(&ctx, &vault, id);
256+
assert!(result.is_ok(), "seed {id}: {:?}", result.err());
257+
}
258+
259+
let modules_root = crate::module::modules_dir(&root);
260+
for id in SYSTEM_MODULES {
261+
let link = modules_root.join(id);
262+
assert!(link.exists(), "{id} enabled and reachable through modules/");
263+
assert!(
264+
link.join("metadata.json").is_file(),
265+
"{id} unpacked with its metadata"
266+
);
267+
}
268+
assert!(missing_system_modules(&modules_root).is_empty(), "nothing left to seed");
269+
270+
std::fs::remove_dir_all(&root).expect("cleanup");
271+
}
272+
240273
#[test]
241274
fn seeds_only_the_system_modules_that_are_absent() {
242275
let dir = std::env::temp_dir().join(format!("spicetify-seed-{}", std::process::id()));

0 commit comments

Comments
 (0)