]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add failure umount missing config attributes
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 17:44:35 +0000 (19:44 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 17:44:35 +0000 (19:44 +0200)
src/backupmount
tests/backupmount_tests.bats

index 681ab5eca67284707392aba4c620ffbfda0c41c0..ce7b79c65a63c142bb742a468c7844164d067a27 100755 (executable)
@@ -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
 
index 01792a5bc94e49ddef804d9c860e62f102222639..e9172a6d35ca62efdd21735f8e550f0b74e97ced 100755 (executable)
@@ -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