phoebus_os/installer-rs/crates/phoebus-installer/tests/plan_golden.rs
Phoebus fe8de3904b
Some checks are pending
ci / test (push) Waiting to run
refactor(desktop): unify desktop stack on Mango + DarkMaterial and excise standalone dwl
- Excised standalone dwl packages: gui-wm/dwl, waybar, wofi, mako, swaybg, swayidle, swaylock
- Removed standalone dwl session and helper assets: PHOEBUS_SESSION_SCRIPT, PHOEBUS_MENU_SCRIPT, PHOEBUS_LOCK_SCRIPT, PHOEBUS_IDLE_SCRIPT, WAYBAR_CONFIG, WAYBAR_STYLE, phoebus-dwl.desktop
- Consolidated DesktopProfile enum to Mango (default) and None (headless), rejecting legacy dwl configurations
- PHOEBUS_MANGO_SESSION_SCRIPT (/usr/local/bin/phoebus-session-mango) fails visibly/diagnostically on error without silent fallback
- Provided /usr/local/bin/phoebus-session as a direct wrapper to phoebus-session-mango
- Live ISO emitted assets reduced from 24 to 17 and verified clean
2026-09-24 15:49:15 -07:00

73 lines
2.5 KiB
Rust

//! Golden-file tests for the Rust installation plan.
//!
//! These pin the exact human-readable plan and destructive preview for a fixed
//! configuration, replacing the Bash/Rust `parity.rs` comparison. Regenerate
//! with `UPDATE_GOLDEN=1 cargo test -p phoebus-installer --test plan_golden`
//! after an intentional plan change, then review the diff.
use std::path::PathBuf;
use phoebus_core::{InstallConfig, InstallPlan};
const CONFIG: &str = "\
HOSTNAME='paritybox'\n\
USERNAME='parityuser'\n\
LOCALE='en_US.UTF-8'\n\
TIMEZONE='UTC'\n\
KEYMAP='us'\n\
TARGET_DISK='/dev/vda'\n\
EFI_SIZE_MIB='1024'\n\
FILESYSTEM='btrfs'\n\
ENCRYPTION='luks2'\n\
COMPRESS='zstd:3'\n\
KERNEL_PROFILE='safe'\n\
KERNEL_CONSOLE='console=tty0'\n\
PACKAGE_POLICY='balanced'\n\
DESKTOP_PROFILE='mango'\n\
BTRFS_SUBVOLS='@ @home @var @snapshots @swap'\n";
fn sample_config() -> InstallConfig {
let dir = tempfile::tempdir().unwrap();
let path = dir.path().join("golden.conf");
std::fs::write(&path, CONFIG).unwrap();
InstallConfig::load_from_path(&path).expect("load golden configuration")
}
fn check_golden(name: &str, actual: &str) {
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("tests/golden")
.join(name);
if std::env::var("UPDATE_GOLDEN").as_deref() == Ok("1") {
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
std::fs::write(&path, actual).unwrap();
return;
}
let expected = std::fs::read_to_string(&path)
.unwrap_or_else(|_| panic!("missing golden file {name}; run with UPDATE_GOLDEN=1"));
assert_eq!(actual, expected, "output drifted from tests/golden/{name}");
}
#[test]
fn plan_output_matches_golden() {
let config = sample_config();
let actual = InstallPlan::for_config(&config).render_human(&config, None);
check_golden("plan.txt", &actual);
}
#[test]
fn destructive_preview_matches_golden() {
let config = sample_config();
let actual = InstallPlan::for_config(&config)
.destructive_preview(&config, "NAME SIZE TYPE\nvda 30G disk");
check_golden("destructive-preview.txt", &actual);
}
#[test]
fn golden_config_is_valid_and_ordered() {
// Guard against a golden that silently stops exercising the real path.
let config = sample_config();
assert_eq!(config.system.hostname, "paritybox");
let steps = InstallPlan::for_config(&config).steps;
assert_eq!(steps.first().map(|s| s.name()), Some("storage_prepare"));
assert_eq!(steps.last().map(|s| s.name()), Some("finalize"));
}