81 lines
3.1 KiB
Rust
81 lines
3.1 KiB
Rust
use archipelago_system::onboarding::*;
|
|
|
|
fn pending() -> Observation {
|
|
Observation {
|
|
context: Context::Installed,
|
|
completion: Completion::Pending,
|
|
account: PrimaryAccount::Absent,
|
|
frontend: Frontend::CoreCli,
|
|
frontend_available: true,
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn installation_first_boot_interruption_and_reboot() {
|
|
let mut state = pending();
|
|
state.context = Context::Live;
|
|
assert_eq!(assess(state), NextStep::Installer);
|
|
state.context = Context::Installed;
|
|
assert_eq!(assess(state), NextStep::Start(Frontend::CoreCli));
|
|
state.account = PrimaryAccount::Incomplete;
|
|
assert_eq!(assess(state), NextStep::Resume(Frontend::CoreCli));
|
|
state.account = PrimaryAccount::Consistent;
|
|
assert_eq!(assess(state), NextStep::Resume(Frontend::CoreCli));
|
|
state.completion = Completion::Complete;
|
|
assert_eq!(assess(state), NextStep::Ready);
|
|
assert_eq!(assess(state), NextStep::Ready);
|
|
}
|
|
|
|
#[test]
|
|
fn configured_core_can_add_desktop_without_new_account_or_wizard() {
|
|
for frontend in [Frontend::GnomeInitialSetup, Frontend::PlasmaSetup] {
|
|
let state = Observation {
|
|
completion: Completion::Complete,
|
|
account: PrimaryAccount::Consistent,
|
|
frontend,
|
|
frontend_available: false,
|
|
..pending()
|
|
};
|
|
assert_eq!(assess(state), NextStep::Ready);
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn missing_native_adapter_does_not_silently_launch_cli() {
|
|
for frontend in [Frontend::GnomeInitialSetup, Frontend::PlasmaSetup] {
|
|
let mut state = Observation { frontend, ..pending() };
|
|
assert_eq!(assess(state), NextStep::Start(frontend));
|
|
state.frontend_available = false;
|
|
assert_eq!(assess(state), NextStep::FrontendUnavailable(frontend));
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn stale_completion_or_conflict_requires_diagnosis() {
|
|
for account in [PrimaryAccount::Absent, PrimaryAccount::Incomplete, PrimaryAccount::Conflict] {
|
|
let state = Observation { account, completion: Completion::Complete, ..pending() };
|
|
assert_eq!(assess(state), NextStep::DiagnoseAccount);
|
|
}
|
|
let state = Observation { account: PrimaryAccount::Conflict, ..pending() };
|
|
assert_eq!(assess(state), NextStep::DiagnoseAccount);
|
|
}
|
|
|
|
#[test]
|
|
fn only_installed_complete_consistent_state_passes_deployment_gate() {
|
|
for context in [Context::Live, Context::Installed] {
|
|
for completion in [Completion::Pending, Completion::Complete] {
|
|
for account in [PrimaryAccount::Absent, PrimaryAccount::Incomplete,
|
|
PrimaryAccount::Consistent, PrimaryAccount::Conflict] {
|
|
for frontend_available in [false, true] {
|
|
let state = Observation {
|
|
context, completion, account, frontend_available, ..pending()
|
|
};
|
|
let expected = context == Context::Installed
|
|
&& completion == Completion::Complete
|
|
&& account == PrimaryAccount::Consistent;
|
|
assert_eq!(assess(state).permits_deployment_preparation(), expected);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|