]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add missing machines config error
authorBastian Dehn <hhaalo@arcor.de>
Tue, 4 Aug 2026 17:04:26 +0000 (19:04 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Tue, 4 Aug 2026 17:04:26 +0000 (19:04 +0200)
src/backup
tests/backup_tests.bats

index b76fc317bd280fa34a3e5fa12e439797152c27fb..b96e982d8dc2dcbbbeabb861c5b7d376a55857b1 100755 (executable)
@@ -67,6 +67,14 @@ exists_backup_count()
        echo "ℹ️ INFO: backup count $backup_count"
 }
 
+exists_machines()
+{
+       local config="$1"
+       echo "$config" | jq --exit-status '.machines' > /dev/null \
+               || errlog "$CONFIG_FILE missing machines" \
+               || return $?
+}
+
 get_last_backup_dir_path()
 {
        local config="$1"
@@ -130,6 +138,7 @@ main()
        exists_backup_path "$config" || return $?
        exists_backup_name "$config" || return $?
        exists_backup_count "$config" || return $?
+       exists_machines "$config" || return $?
 
        last_backup_dir_path=$(get_last_backup_dir_path "$config")
        [ -n "$last_backup_dir_path" ] \
index 117b47e55f703f446411a5a740151f3377ba2a54..1189759ffa099aacf8c6ce506ef9d1f3a2956a7e 100755 (executable)
@@ -145,6 +145,25 @@ teardown() {
        assert_line --index 3 "❌ ERROR: src/config-example.yaml missing backup_count"
 }
 
+@test "failure no machines in config" {
+       yq() {
+               echo '{
+                       "backup_path": "path",
+                       "backup_name": "backup",
+                       "backup_count": 15
+                       }'
+       }
+
+       run main
+
+       assert_failure
+       assert_line --index 0 "⭐ START: backup"
+       assert_line --index 1 "ℹ️ INFO: backup path path"
+       assert_line --index 2 "ℹ️ INFO: backup name backup"
+       assert_line --index 3 "ℹ️ INFO: backup count 15"
+       assert_line --index 4 "❌ ERROR: src/config-example.yaml missing machines"
+}
+
 @test "success info backup count" {
        create_backup_dir() {
                :