From: Bastian Dehn Date: Fri, 25 Sep 2026 07:16:53 +0000 (+0200) Subject: add test for missing config file X-Git-Tag: v1.0.0^2~7^2~37 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=c8acbb7f3ceb9804031826f4419541e68a75a8f0;p=albentohandy.git add test for missing config file --- diff --git a/src/albentohandy b/src/albentohandy index ae8107f..c19e75c 100755 --- a/src/albentohandy +++ b/src/albentohandy @@ -14,6 +14,12 @@ main() command -v rsync > /dev/null \ || errlog "command rsync not found" \ || return $? + + CONFIG_FILE=${CONFIG_FILE:="$HOME/.albentohandy.conf"} + + [ -f "$CONFIG_FILE" ] \ + || errlog "missing $CONFIG_FILE" \ + || return $? } [ "$TEST_MODE" == "ON" ] && return 0 diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index 7180ddd..e3f98c5 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -4,6 +4,7 @@ setup() { bats_load_library 'bats-support' bats_load_library 'bats-assert' export TEST_MODE="ON" + export CONFIG_FILE="src/albentohandy.conf" source src/albentohandy } @@ -20,4 +21,13 @@ teardown() { assert_failure assert_line --index 0 "❌ ERROR: command rsync not found" +} + +@test "failed: missing albumtohandy.conf" { + CONFIG_FILE="src/nothing.conf" + + run main + + assert_failure + assert_line --index 0 "❌ ERROR: missing src/nothing.conf" } \ No newline at end of file