test(system.just): BATS coverage for toggle-testing, toggle-vms, install-system-flatpaks - #1031
Merged
Merged
Conversation
…install-system-flatpaks
system_files/bluefin/usr/share/ublue-os/just/system.just is the largest
untested file in the repo — 388 lines, zero tests — and toggle-testing is
the recipe that computes the ref handed to `bootc switch`. A mistake in
its channel mapping moves a user's machine onto the wrong image, and
nothing in the repo would catch it.
tests/test_system_just.bats extracts each recipe body out of the justfile
into a standalone script and runs it against mocked jq/gum/pkexec/bootc/
flatpak/brew/just, so no host state is touched. 24 tests:
toggle-testing (14)
- stable/latest -> testing, lts -> lts-testing, lts-hwe -> lts-hwe-testing
- testing -> stable, lts-testing -> lts, lts-hwe-testing -> lts-hwe
(guards the ${IMAGE_TAG/-testing/} path that must not collapse to
"stable" for the LTS channels)
- unrecognised channel exits 1 and issues no switch
- transport-prefix stripping for ostree-image-signed:docker:// and
ostree-unverified-registry:, plus a bare registry ref
- declining either gum confirm switches nothing
- the switch is issued through pkexec
toggle-vms (6)
- installs when virt-manager is absent, removes when present
- removal covers the QEMU extension and strips only the session
uri_default line from libvirt.conf
- both declined prompts are no-ops
install-system-flatpaks (4)
- confirm=0 skips the prompt, confirm=1 requires it
- declining installs nothing
- TARGET_FLATPAK_FILE overrides the default Brewfile
Wired into `just test`. The extractor asserts a non-empty recipe body so a
rename fails loudly instead of silently testing nothing. Verified by
mutation: flipping the lts-hwe mapping fails the suite.
The unit-tests.yml step is deliberately not in this PR — see the PR body.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: kubestellar-hive[bot] <kubestellar-hive[bot]@users.noreply.github.com>
This was referenced Aug 28, 2026
hanthor
approved these changes
Sep 2, 2026
hanthor
left a comment
Member
There was a problem hiding this comment.
New tests/test_system_just.bats (24 cases) for toggle-testing, toggle-vms, install-system-flatpaks, including the lts/lts-hwe vs. stable collapse-prevention cases and libvirt.conf uri_default stripping. CI test green; validate fails only on title-lint.
Generated by Claude Code
castrojo
approved these changes
Sep 10, 2026
castrojo
left a comment
Contributor
There was a problem hiding this comment.
Review: PR #1031 ([quality] test(system.just): BATS coverage for toggle-testing, toggle-vms, install-system-flatpaks)
Findings
- Scope and Implementation:
- Adds 24 BATS tests in
tests/test_system_just.batscoveringtoggle-testing(both directions, collapse-prevention forlts/lts-hwe),toggle-vms(install/remove paths, libvirt.conf cleanup), andinstall-system-flatpaks(prompting, file overrides). - Clean recipe extraction and mocking without modifying production code or executing host changes.
- Adds 24 BATS tests in
- Verification:
- CI suite passes (
validate,test,Build,PR E2E).
- CI suite passes (
Verdict
Approved.
castrojo
enabled auto-merge
September 10, 2026 02:15
pull Bot
pushed a commit
to joshyorko/common
that referenced
this pull request
Sep 10, 2026
…boot-key, toggle-user-motd, check-local-overrides, check-idle-power-draw, benchmark (projectbluefin#1048) ## Test Improvement Adds `tests/test_default_just.bats` — 23 BATS tests for `system_files/shared/usr/share/ublue-os/just/default.just`. Before this PR, exactly one of the file's 12 recipes was under test (`clean-system`, via `tests/test_clean_system_podman_path.bats`). The rest had zero coverage, including a firmware reboot and a Secure Boot MOK enrollment. ### Recipes claimed by this PR | Recipe | What is covered | |---|---| | `bios` | legacy-BIOS guard exits 1 and never reboots; EFI + confirm issues `systemctl reboot --firmware-setup`; declined confirmation does not reboot | | `bios-info` | all four `dmidecode -s` fields read under `sudo bash`; every field is labelled | | `enroll-secure-boot-key` | `mokutil --timeout -1` precedes the import; `akmods-ublue.der` is the imported cert; enrollment password guidance is printed | | `toggle-user-motd` | shim body is exactly `uwelcome toggle` | | `check-local-overrides` | only-in-`/etc` reporting; content divergence reporting; silence when trees match; `NO_COLOR=1` palette suppression; palette applied when unset; identity/credential `--exclude` set | | `check-idle-power-draw` | missing-`powerstat` guard exits 1 without invoking it; present path runs `powerstat -a -r` | | `benchmark` | `stress-ng` present runs the 1m matrix load without touching brew; accept path runs `brew install`/`brew link` then the load; decline path exits 0 with no install | ### Method Each shebang recipe body is extracted verbatim from `default.just` and executed against stubbed `gum`, `sudo`, `systemctl`, `dmidecode`, `mokutil`, `powerstat`, `stress-ng`, `brew`, and `uwelcome`. `/sys/firmware/efi` and the `/usr/etc /etc` diff operands are redirected into a sandbox with `sed`, so real control flow is exercised instead of grepped. `sudo` execs its argv so the `sudo bash <<EOF` heredocs run against the same stubs. ### Incidental finding pinned, not fixed `check-local-overrides` hardcodes `diff --color="always"`. `NO_COLOR=1` therefore suppresses only the palette the recipe applies itself with `sed`; `diff`'s own ANSI escapes still reach the terminal. One test documents that current behaviour so a future fix is visible. No production code is changed by this PR. ### Disjointness Explicitly claims only the seven recipes listed above in `default.just`, plus the new test file. - `device-info` (`default.just`) — **left to PR projectbluefin#1003**, not touched or asserted on. - `clean-system` (`default.just`) — already owned by `tests/test_clean_system_podman_path.bats`. - `shared.just` — left to PR projectbluefin#1034. - `system.just` — left to PR projectbluefin#1031. - `apps.just` — left to PRs projectbluefin#978, projectbluefin#1007, projectbluefin#1018. - `changelog.just` / `ublue-image-repo` — left to PR projectbluefin#1045. `Justfile`: one line, `bats tests/test_default_just.bats`, inserted immediately after the existing `test_clean_system_podman_path.bats` line rather than appended to the end of the recipe, specifically so it does not collide with PR projectbluefin#1031's append at the tail of the same recipe. `.github/workflows/unit-tests.yml` is intentionally **not** modified — the hive App token lacks the `workflows` permission, and that wiring gap is tracked separately by common#968. ### Verification ``` $ bats tests/test_default_just.bats 1..23 ok 1 .. ok 23 ``` ## Related Issue Refs projectbluefin#968 (the workflow-wiring half of the gap remains open). --- *Filed by quality agent (hold-gated mode). Human review required.* — hive: agent=quality backend=copilot model=claude-opus-5 Signed-off-by: quality <sec-check[bot]@users.noreply.github.com> Co-authored-by: quality <sec-check[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cluster claimed
File under test:
system_files/bluefin/usr/share/ublue-os/just/system.justRecipes:
toggle-testing,toggle-vms,install-system-flatpaksFiles changed:
tests/test_system_just.bats(new),Justfile(one line)No other file is touched. In particular this PR does not modify
.github/workflows/unit-tests.yml— see Known follow-up below.Why
system.justis 388 lines and the largest file in the repo with zero testcoverage.
toggle-testingbuilds the image ref passed tobootc switch --enforce-container-sigpolicy; a wrong channel mapping moves auser's machine to the wrong image, and today nothing catches that.
What
tests/test_system_just.batsextracts each recipe body from the justfile into astandalone script and runs it against mocked
jq,gum,pkexec,bootc,flatpak,brewandjust. Nothing on the host is read or written. 24 tests:toggle-testingostree-image-signed:docker://,ostree-unverified-registry:, bare ref); both declined prompts are no-ops; switch goes throughpkexectoggle-vmsuri_defaultline stripped fromlibvirt.conf; declined prompts are no-opsinstall-system-flatpaksconfirm=0skips the prompt,confirm=1requires it; declining installs nothing;TARGET_FLATPAK_FILEoverride honouredThe
lts-testing → ltsandlts-hwe-testing → lts-hwecases specifically pinthe
${IMAGE_TAG/-testing/}branch, which must not collapse the LTS channelsdown to
stable.Verification
Mutation-checked: flipping the
lts-hwemapping totestingfails the suite,so the tests bite rather than merely execute.
Known follow-up — CI wiring
The new file is wired into
just test, but not into.github/workflows/unit-tests.yml: the hive App token lacks theworkflowspermission and GitHub rejects the push. A maintainer adding this one step makes
it run in CI:
Same blocker applies to #968 (9 test files already in
tests/and injust testthatunit-tests.ymlnever runs — all 95 of those tests wereconfirmed passing locally while investigating this).
Overlap check
Compared against every open PR in the snapshot. Nearest neighbours:
[sec-check]permissions block) and fix(ci): declare top-level permissions: {} in e2e.yml pr-e2e.yml promotion-candidate-e2e.yml #969/fix(brew): use valid brew tap trust commands #978/feat: add richer Bluefin fastfetch colors #980/fix: add consistent bootc sudo policy #932 — nonetouch
system.just,tests/or theJustfile. fix(ci): unit-tests.yml add permissions block (contents: read) #961 editsunit-tests.yml, which this PR deliberately leaves alone, so there is noconflict.
system.justrecipes.Disjoint.
Filed by the quality agent (hold-gated mode). Human review required — do not merge on my account.
— hive: agent=quality backend=copilot model=claude-opus-5