Skip to content

Commit 9b18985

Browse files
committed
test: Modify the test to handle missing fields safely
Signed-off-by: Xiaofeng Wang <[email protected]>
1 parent 03ff8a8 commit 9b18985

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

tmt/tests/booted/test-soft-reboot.nu

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,18 @@ RUN echo test content > /usr/share/testfile-for-soft-reboot.txt
2929
podman build -t localhost/bootc-derived .
3030

3131
assert (not ("/run/nextroot" | path exists))
32-
32+
3333
bootc switch --soft-reboot=auto --transport containers-storage localhost/bootc-derived
34+
3435
let st = bootc status --json | from json
35-
assert $st.status.staged.softRebootCapable
36+
37+
let staged_soft = ($st.status.staged.softRebootCapable? | default false)
38+
let booted_soft = ($st.status.booted.softRebootCapable? | default false)
39+
40+
assert ($st.status.staged != null) # staged must exist for this test
41+
assert $st.status.staged.image != null # optional: staged image must exist
42+
assert $st.status.booted.image != null # sanity check
43+
assert ($staged_soft or $booted_soft) # at least one must support soft reboot
3644

3745
assert ("/run/nextroot" | path exists)
3846

0 commit comments

Comments
 (0)