From: Bastian Dehn Date: Sun, 16 Aug 2026 17:44:35 +0000 (+0200) Subject: add failure umount missing config attributes X-Git-Tag: v1.0.7^2~1^2~8 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=b8421444a96cd98c06fd213c235511d13b350939;p=simple-backup.git add failure umount missing config attributes --- diff --git a/src/backupmount b/src/backupmount index 681ab5e..ce7b79c 100755 --- a/src/backupmount +++ b/src/backupmount @@ -146,7 +146,20 @@ mount_backup() umount_backup() { - : + local config="$1" + local backup_path= + local volume= + + backup_path=$(echo "$config" \ + | jq --raw-output ".backup_path") + [ "$backup_path" != "null" ] \ + || errlog "missing backup path in $CONFIG_FILE" \ + || return $? + volume=$(echo "$config" \ + | jq --raw-output ".backup_volume") + [ "$volume" != "null" ] \ + || errlog "missing backup volume in $CONFIG_FILE" \ + || return $? } main() @@ -168,7 +181,7 @@ main() case $cmd in "mount") mount_backup "$config" || return $? ;; - "umount") umount_backup || return $? ;; + "umount") umount_backup "$config" || return $? ;; *) errlog "unknown command" && return 1 ;; esac diff --git a/tests/backupmount_tests.bats b/tests/backupmount_tests.bats index 01792a5..e9172a6 100755 --- a/tests/backupmount_tests.bats +++ b/tests/backupmount_tests.bats @@ -454,4 +454,30 @@ teardown() { assert_line --index 4 "ℹ️ INFO: create backup path build/test" assert_line --index 5 "ℹ️ INFO: mount /dev/path/to/partday to build/test" assert_line --index 6 "❌ ERROR: could not mount /dev/path/to/partday to build/test" +} + +# bats test_tags=backupmount:umount +@test "failure umount missing backup path" { + yq() { + echo '{}' + } + + run main "umount" + + assert_failure + assert_line --index 0 "⭐ START: backupmount" + assert_line --index 1 "❌ ERROR: missing backup path in src/config-example.yaml" +} + +# bats test_tags=backupmount:umount +@test "failure umount missing backup volume" { + yq() { + echo '{"backup_path": "build/test"}' + } + + run main "umount" + + assert_failure + assert_line --index 0 "⭐ START: backupmount" + assert_line --index 1 "❌ ERROR: missing backup volume in src/config-example.yaml" } \ No newline at end of file