From 41e4c449422ad61022bb194c8d871d9fd9abc593 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 16 Aug 2026 15:59:41 +0200 Subject: [PATCH] add check command exists --- src/backupmount | 5 +++++ tests/backupmount_tests.bats | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/backupmount b/src/backupmount index 20f31d4..f68157f 100755 --- a/src/backupmount +++ b/src/backupmount @@ -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 diff --git a/tests/backupmount_tests.bats b/tests/backupmount_tests.bats index 786aad5..dc164fd 100755 --- a/tests/backupmount_tests.bats +++ b/tests/backupmount_tests.bats @@ -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 -- 2.47.3