From c8acbb7f3ceb9804031826f4419541e68a75a8f0 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 09:16:53 +0200 Subject: [PATCH] add test for missing config file --- src/albentohandy | 6 ++++++ tests/albentohandy.bats | 10 ++++++++++ 2 files changed, 16 insertions(+) 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 -- 2.47.3