Skip to content

[quality] test(system.just): BATS coverage for toggle-testing, toggle-vms, install-system-flatpaks - #1031

Open
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/system-just-bats-tests
Open

[quality] test(system.just): BATS coverage for toggle-testing, toggle-vms, install-system-flatpaks#1031
kubestellar-hive[bot] wants to merge 1 commit into
mainfrom
quality/system-just-bats-tests

Conversation

@kubestellar-hive

Copy link
Copy Markdown
Contributor

Cluster claimed

File under test: system_files/bluefin/usr/share/ublue-os/just/system.just
Recipes: toggle-testing, toggle-vms, install-system-flatpaks
Files 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.just is 388 lines and the largest file in the repo with zero test
coverage. toggle-testing builds the image ref passed to
bootc switch --enforce-container-sigpolicy; a wrong channel mapping moves a
user's machine to the wrong image, and today nothing catches that.

What

tests/test_system_just.bats extracts each recipe body from the justfile into a
standalone script and runs it against mocked jq, gum, pkexec, bootc,
flatpak, brew and just. Nothing on the host is read or written. 24 tests:

Recipe Tests Covers
toggle-testing 14 stable/latest → testing; lts → lts-testing; lts-hwe → lts-hwe-testing; testing → stable; lts-testing → lts; lts-hwe-testing → lts-hwe; unknown channel exits 1 with no switch; transport-prefix stripping (ostree-image-signed:docker://, ostree-unverified-registry:, bare ref); both declined prompts are no-ops; switch goes through pkexec
toggle-vms 6 install when absent / remove when present; QEMU extension included in removal; only the session uri_default line stripped from libvirt.conf; declined prompts are no-ops
install-system-flatpaks 4 confirm=0 skips the prompt, confirm=1 requires it; declining installs nothing; TARGET_FLATPAK_FILE override honoured

The lts-testing → lts and lts-hwe-testing → lts-hwe cases specifically pin
the ${IMAGE_TAG/-testing/} branch, which must not collapse the LTS channels
down to stable.

Verification

$ bats tests/test_system_just.bats
1..24
ok 1 .. ok 24

Mutation-checked: flipping the lts-hwe mapping to testing fails 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 the workflows
permission and GitHub rejects the push. A maintainer adding this one step makes
it run in CI:

      - name: Run bats (system.just)
        run: bats tests/test_system_just.bats

Same blocker applies to #968 (9 test files already in tests/ and in
just test that unit-tests.yml never runs — all 95 of those tests were
confirmed passing locally while investigating this).

Overlap check

Compared against every open PR in the snapshot. Nearest neighbours:

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

…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>

@hanthor hanthor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Work is intentionally paused.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant