]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add test check no device for media
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 14:38:03 +0000 (16:38 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 14:38:03 +0000 (16:38 +0200)
src/backupmount
tests/backupmount_tests.bats

index fc8c228b6ff43e08fca22e51194ab39851b63458..51ba77048de07c75d10fc0921cecabd760b8a9c4 100755 (executable)
@@ -40,6 +40,16 @@ mount_backup()
        [ "${#media[@]}" -gt 0 ] \
                || errlog "missing media in $CONFIG_FILE" \
                || return $?
+
+       local device=
+       local one_media=
+       for one_media in "${media[@]}"; do
+               device=$(echo "$config" \
+                       | jq --raw-output ".media.\"$one_media\".device")
+               [ "$device" != "null" ] \
+                       || errlog "missing device for media $one_media in $CONFIG_FILE" \
+                       || return $?
+       done
 }
 
 umount_backup()
index cd269957ff248219a4733f81fb8e7696334ddefc..0823c9ba5a76e9b53a43dfb3c50007822dede572 100755 (executable)
@@ -114,4 +114,21 @@ teardown() {
        assert_failure
        assert_line --index 0 "⭐ START: backupmount"
        assert_line --index 1 "❌ ERROR: missing media in src/config-example.yaml"
+}
+
+# bats test_tags=backupmount:mount
+@test "failure no device for media day" {
+       yq() {
+               echo '{
+                       "media": {
+                               "day": {}
+                       }
+               }'
+       }
+
+       run main "mount"
+
+       assert_failure
+       assert_line --index 0 "⭐ START: backupmount"
+       assert_line --index 1 "❌ ERROR: missing device for media day in src/config-example.yaml"
 }
\ No newline at end of file