mirror of
https://github.com/containers/bootc.git
synced 2026-02-05 15:45:53 +01:00
tests(status): add tests for --booted
Signed-off-by: Robert Sturla <robertsturla@outlook.com>
This commit is contained in:
@@ -316,4 +316,49 @@ mod tests {
|
||||
assert!(Store::from_str("OstrEeContAiner", true).is_ok());
|
||||
assert!(Store::from_str("invalid", true).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_host_filter_to_slot() {
|
||||
fn create_host() -> Host {
|
||||
let mut host = Host::default();
|
||||
host.status.staged = Some(default_boot_entry());
|
||||
host.status.booted = Some(default_boot_entry());
|
||||
host.status.rollback = Some(default_boot_entry());
|
||||
host
|
||||
}
|
||||
|
||||
fn default_boot_entry() -> BootEntry {
|
||||
BootEntry {
|
||||
image: None,
|
||||
cached_update: None,
|
||||
incompatible: false,
|
||||
pinned: false,
|
||||
store: None,
|
||||
ostree: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn assert_host_state(
|
||||
host: &Host,
|
||||
staged: Option<BootEntry>,
|
||||
booted: Option<BootEntry>,
|
||||
rollback: Option<BootEntry>,
|
||||
) {
|
||||
assert_eq!(host.status.staged, staged);
|
||||
assert_eq!(host.status.booted, booted);
|
||||
assert_eq!(host.status.rollback, rollback);
|
||||
}
|
||||
|
||||
let mut host = create_host();
|
||||
host.filter_to_slot(Slot::Staged);
|
||||
assert_host_state(&host, Some(default_boot_entry()), None, None);
|
||||
|
||||
let mut host = create_host();
|
||||
host.filter_to_slot(Slot::Booted);
|
||||
assert_host_state(&host, None, Some(default_boot_entry()), None);
|
||||
|
||||
let mut host = create_host();
|
||||
host.filter_to_slot(Slot::Rollback);
|
||||
assert_host_state(&host, None, None, Some(default_boot_entry()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,18 @@ tap begin "verify bootc status output formats"
|
||||
|
||||
let st = bootc status --json | from json
|
||||
assert equal $st.apiVersion org.containers.bootc/v1
|
||||
|
||||
let st = bootc status --json --format-version=0 | from json
|
||||
assert equal $st.apiVersion org.containers.bootc/v1
|
||||
|
||||
let st = bootc status --format=yaml | from yaml
|
||||
assert equal $st.apiVersion org.containers.bootc/v1
|
||||
assert ($st.status.booted.image.timestamp != null)
|
||||
|
||||
let st = bootc status --json --booted | from json
|
||||
assert equal $st.apiVersion org.containers.bootc/v1
|
||||
assert ($st.status.booted.image.timestamp != null)
|
||||
assert (($st.status | get rollback | default null) == null)
|
||||
assert (($st.status | get staged | default null) == null)
|
||||
|
||||
tap ok
|
||||
|
||||
Reference in New Issue
Block a user