aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/test_archangel.bats
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-27 12:45:48 -0500
committerCraig Jennings <c@cjennings.net>2026-04-27 12:45:48 -0500
commit8c69aaaff13da3b7d1d24ed34975e8c5b30409e6 (patch)
treeb296d568c124d1d8ca83275e8c197c1c0d53bca0 /tests/unit/test_archangel.bats
parent822075bf99cda84782ef04419855f6c289a6fc13 (diff)
downloadarchangel-8c69aaaff13da3b7d1d24ed34975e8c5b30409e6.tar.gz
archangel-8c69aaaff13da3b7d1d24ed34975e8c5b30409e6.zip
refactor: consolidate installer defaults and FILESYSTEM validation into config.sh
The installer had three sites touching FILESYSTEM: a top-level default in the monolith, a re-default block in gather_input, and a runtime validation block also in gather_input. The same scattering existed for LOCALE, KEYMAP, ENABLE_SSH, and NO_ENCRYPT. A future contributor changing one site wouldn't have known the other two existed. Move all five defaults into the lib/config.sh declarations so config.sh is the single source of truth. Add validate_filesystem() in lib/config.sh and call it from main() between check_config and gather_input, so a typo in a config file's FILESYSTEM= fails fast before any install action runs. The behavior change is stricter. An empty FILESYSTEM in a config file used to be silently defaulted to zfs, now it errors. Interactive mode is unaffected. select_filesystem still controls the value and already errored on cancellation. Bats: 140 → 142. Five tests added in test_config.bats for the defaults pinning and validate_filesystem coverage. Three removed from test_archangel.bats for behavior that moved out of gather_input. Lint clean.
Diffstat (limited to 'tests/unit/test_archangel.bats')
-rw-r--r--tests/unit/test_archangel.bats45
1 files changed, 6 insertions, 39 deletions
diff --git a/tests/unit/test_archangel.bats b/tests/unit/test_archangel.bats
index ccabec7..749f786 100644
--- a/tests/unit/test_archangel.bats
+++ b/tests/unit/test_archangel.bats
@@ -70,33 +70,9 @@ setup() {
#############################
# Optional-field defaults
#############################
-
-@test "gather_input unattended defaults FILESYSTEM to zfs when empty" {
- HOSTNAME=h
- TIMEZONE=UTC
- ROOT_PASSWORD=x
- SELECTED_DISKS=(/dev/sda)
- FILESYSTEM=""
- NO_ENCRYPT=yes
- gather_input >/dev/null
- [ "$FILESYSTEM" = "zfs" ]
-}
-
-@test "gather_input unattended defaults LOCALE, KEYMAP, ENABLE_SSH when empty" {
- HOSTNAME=h
- TIMEZONE=UTC
- ROOT_PASSWORD=x
- SELECTED_DISKS=(/dev/sda)
- FILESYSTEM=zfs
- NO_ENCRYPT=yes
- LOCALE=""
- KEYMAP=""
- ENABLE_SSH=""
- gather_input >/dev/null
- [ "$LOCALE" = "en_US.UTF-8" ]
- [ "$KEYMAP" = "us" ]
- [ "$ENABLE_SSH" = "yes" ]
-}
+# Default values themselves are pinned in test_config.bats (config.sh
+# is the single source of truth). The remaining test here covers the
+# adjacent guarantee: gather_input doesn't clobber values the user set.
@test "gather_input unattended preserves explicit non-default values" {
HOSTNAME=h
@@ -160,18 +136,9 @@ setup() {
#############################
# Filesystem validity
#############################
-
-@test "gather_input unattended errors when FILESYSTEM is neither zfs nor btrfs" {
- HOSTNAME=h
- TIMEZONE=UTC
- ROOT_PASSWORD=x
- SELECTED_DISKS=(/dev/sda)
- FILESYSTEM=ext4
- NO_ENCRYPT=yes
- run gather_input
- [ "$status" -eq 1 ]
- [[ "$output" == *"Invalid FILESYSTEM"* ]]
-}
+# Validation moved to validate_filesystem in lib/config.sh — covered
+# by test_config.bats. main() calls it between check_config and
+# gather_input so a bad FILESYSTEM= never reaches install time.
#############################
# RAID-level defaulting