]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add volume missing test
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 15:19:37 +0000 (17:19 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 15:19:37 +0000 (17:19 +0200)
src/backupmount
tests/backupmount_tests.bats

index 0ad4b658b776bde2e5558aed60fde002a09841bd..4fdd547f4212b7ca331f95059c48c7b650ae8627 100755 (executable)
@@ -57,6 +57,7 @@ mount_device()
        local media="$2"
        local device=
        local key=
+       local volume=
 
        device=$(echo "$config" \
                | jq --raw-output ".media.\"$media\".device")
@@ -72,6 +73,13 @@ mount_device()
                || errlog "missing key for media $media in $CONFIG_FILE" \
                || return $?
        exists_key "$media" "$key" || return $?
+       echo "ℹ️ INFO: use key $key"
+
+       volume=$(echo "$config" \
+               | jq --raw-output ".media.\"$media\".volume")
+       [ "$volume" != "null" ] \
+               || errlog "missing volume in $CONFIG_FILE" \
+               || return $?
 }
 
 mount_backup()
index 6e7aceda178e7036e3405d71148a9f47419eddf7..6dbcfbc6b690d4bf516712c94f14b4441b0cc302 100755 (executable)
@@ -190,4 +190,32 @@ teardown() {
        assert_line --index 0 "⭐ START: backupmount"
        assert_line --index 1 "ℹ️ INFO: media day with device /dev/path/to/day found"
        assert_line --index 2 "❌ ERROR: key notexistskey for media day not exists"
+}
+
+# bats test_tags=backupmount:mount
+@test "failure missing volume for media day" {
+       yq() {
+               echo '{
+                       "media": {
+                               "day": {
+                                       "device": "/dev/path/to/day",
+                                       "key": "/path/to/key"
+                               }
+                       }
+               }'
+       }
+       exists_block_device() {
+               return 0
+       }
+       exists_key() {
+               return 0
+       }
+
+       run main "mount"
+
+       assert_failure
+       assert_line --index 0 "⭐ START: backupmount"
+       assert_line --index 1 "ℹ️ INFO: media day with device /dev/path/to/day found"
+       assert_line --index 2 "ℹ️ INFO: use key /path/to/key"
+       assert_line --index 3 "❌ ERROR: missing volume in src/config-example.yaml"
 }
\ No newline at end of file