diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-13 00:10:17 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-13 00:10:17 -0400 |
| commit | bc613e72238f864a597777826d1f9cc533c4cffa (patch) | |
| tree | e36ec8edf7e7965f99dacfe6b15e9ca75d70e202 /tests/unit | |
| parent | 9f6c75916cee8cb65b21b71c69f62d080818ad63 (diff) | |
| download | archangel-bc613e72238f864a597777826d1f9cc533c4cffa.tar.gz archangel-bc613e72238f864a597777826d1f9cc533c4cffa.zip | |
refactor: merge install_base and install_base_btrfs
Extract the pacstrap package list into pacstrap_packages(filesystem)
in lib/common.sh (common + filesystem-specific). install_base() now
dispatches on FILESYSTEM for both the archzfs-repo-append and the
package list. install_base_btrfs() deleted; install_btrfs() call site
updated to invoke install_base.
Old: 49 + 38 lines of ~95% copy-paste.
New: 32 lines + a 20-line pure helper.
7 bats tests cover: zfs has zfs-dkms/zfs-utils, btrfs has btrfs-progs
+ grub + grub-btrfs + snapper + snap-pac, each flavor excludes the
other's specifics, common packages are in both, unknown filesystem
returns status 1, output is one-per-line. make test: 65/65.
Diffstat (limited to 'tests/unit')
| -rw-r--r-- | tests/unit/test_common.bats | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/unit/test_common.bats b/tests/unit/test_common.bats index f0e3e21..04f4e09 100644 --- a/tests/unit/test_common.bats +++ b/tests/unit/test_common.bats @@ -88,6 +88,69 @@ setup() { } ############################# +# pacstrap_packages +############################# + +@test "pacstrap_packages zfs includes zfs-dkms and zfs-utils" { + run pacstrap_packages zfs + [ "$status" -eq 0 ] + [[ "$output" == *"zfs-dkms"* ]] + [[ "$output" == *"zfs-utils"* ]] +} + +@test "pacstrap_packages btrfs includes btrfs-progs, grub, grub-btrfs, snapper, snap-pac" { + run pacstrap_packages btrfs + [ "$status" -eq 0 ] + [[ "$output" == *"btrfs-progs"* ]] + [[ "$output" == *"grub"* ]] + [[ "$output" == *"grub-btrfs"* ]] + [[ "$output" == *"snapper"* ]] + [[ "$output" == *"snap-pac"* ]] +} + +@test "pacstrap_packages zfs excludes Btrfs-specific packages" { + run pacstrap_packages zfs + [ "$status" -eq 0 ] + [[ "$output" != *"btrfs-progs"* ]] + [[ "$output" != *"grub-btrfs"* ]] + [[ "$output" != *"snapper"* ]] +} + +@test "pacstrap_packages btrfs excludes ZFS-specific packages" { + run pacstrap_packages btrfs + [ "$status" -eq 0 ] + [[ "$output" != *"zfs-dkms"* ]] + [[ "$output" != *"zfs-utils"* ]] +} + +@test "pacstrap_packages includes common packages for both filesystems" { + for fs in zfs btrfs; do + run pacstrap_packages "$fs" + [ "$status" -eq 0 ] + [[ "$output" == *"base"* ]] + [[ "$output" == *"linux-lts"* ]] + [[ "$output" == *"efibootmgr"* ]] + [[ "$output" == *"networkmanager"* ]] + [[ "$output" == *"openssh"* ]] + [[ "$output" == *"inetutils"* ]] + done +} + +@test "pacstrap_packages unknown filesystem returns status 1" { + run pacstrap_packages reiserfs + [ "$status" -eq 1 ] + [ -z "$output" ] +} + +@test "pacstrap_packages emits one package per line" { + run pacstrap_packages zfs + [ "$status" -eq 0 ] + local expected_lines + expected_lines=$(echo "$output" | wc -l) + [ "$expected_lines" -ge 20 ] +} + +############################# # prompt_password ############################# |
