]> gitweb.hhaalo.de Git - simple-backup.git/commitdiff
add check command exists
authorBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 13:59:41 +0000 (15:59 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 16 Aug 2026 13:59:41 +0000 (15:59 +0200)
src/backupmount
tests/backupmount_tests.bats

index 20f31d4a0746835352ec324230120261e0d71553..f68157fd7adefa4495cf3556b0e9f21a8ef5432c 100755 (executable)
@@ -27,6 +27,11 @@ main()
        local CONFIG_FILE=${CONFIG_FILE:="config.yaml"}
        exists_needed_commands || return $?
        echo "⭐ START: backupmount"
+
+       local cmd="$1"
+       [ -n "$md" ] \
+               || errlog "missing command" \
+               || return $?
 }
 
 [ "$TESTMODE" == "ON" ] && return 0
index 786aad52abf5fd0566db9dbdcdb3ed8877a73bc9..dc164fd3c550b394ff875a9219bdab2a74752927 100755 (executable)
@@ -19,6 +19,7 @@ teardown() {
        exists_needed_commands() {
                return 0
        }
+
        run main
 
        assert_line --index 0 "⭐ START: backupmount"
@@ -58,4 +59,17 @@ teardown() {
 
        assert_failure
        assert_line --index 0 "❌ ERROR: command cryptsetup not found"
+}
+
+# bats test_tags=backupmount:start
+@test "failure missing command parameter" {
+       exists_needed_commands() {
+               return 0
+       }
+
+       run main
+
+       assert_failure
+       assert_line --index 0 "⭐ START: backupmount"
+       assert_line --index 1 "❌ ERROR: missing command"
 }
\ No newline at end of file