From 398384fe76a31cecd18935df72561aea84437f74 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 10:31:31 +0200 Subject: [PATCH] add test for albumlist file --- src/albentohandy | 6 ++++++ src/lib/vorbis.sh | 0 tests/albentohandy.bats | 26 ++++++++++++++++++++++---- tests/test.conf | 3 +-- 4 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 src/lib/vorbis.sh diff --git a/src/albentohandy b/src/albentohandy index 3af2253..a5cc59b 100755 --- a/src/albentohandy +++ b/src/albentohandy @@ -36,6 +36,7 @@ load_config() main() { + local albumlist=${albumlist:-"albumlist"} local lib="vorbis.sh" check_programs || return $? load_config || return $? @@ -52,6 +53,11 @@ main() [ -f "$LIB_PATH/$lib" ] \ || errlog "lib $LIB_PATH/$lib not found" \ || return $? + + + [ -f "$albumlist" ] \ + || errlog "file $albumlist does not exists" \ + || return $? } [ "$TEST_MODE" == "ON" ] && return 0 diff --git a/src/lib/vorbis.sh b/src/lib/vorbis.sh new file mode 100644 index 0000000..e69de29 diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index 091dbbe..f7524cf 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -6,12 +6,15 @@ setup() { mkdir --parents "build/tests" export TEST_MODE="ON" export CONFIG_FILE="tests/test.conf" + export LIB_PATH="src/lib" source src/albentohandy } teardown() { rm --recursive --force "build" unset TEST_MODE + unset CONFIG_FILE + unset LIB_PATH } @test "failed: rsync not found" { @@ -45,31 +48,39 @@ teardown() { } @test "failed: lib vorbis.sh not found" { + LIB_PATH="build/tests/lib" + run main assert_failure - assert_line --index 0 "❌ ERROR: lib src/lib/vorbis.sh not found" + assert_line --index 0 "❌ ERROR: lib build/tests/lib/vorbis.sh not found" } @test "failed: lib mp3.sh not found" { + LIB_PATH="build/tests/lib" + run main -3 assert_failure - assert_line --index 0 "❌ ERROR: lib src/lib/mp3.sh not found" + assert_line --index 0 "❌ ERROR: lib build/tests/lib/mp3.sh not found" } @test "failed: lib flac.sh not found" { + LIB_PATH="build/tests/lib" + run main -f assert_failure - assert_line --index 0 "❌ ERROR: lib src/lib/flac.sh not found" + assert_line --index 0 "❌ ERROR: lib build/tests/lib/flac.sh not found" } @test "failed: lib opus.sh not found" { + LIB_PATH="build/tests/lib" + run main -o assert_failure - assert_line --index 0 "❌ ERROR: lib src/lib/opus.sh not found" + assert_line --index 0 "❌ ERROR: lib build/tests/lib/opus.sh not found" } @test "failed: unknown option" { @@ -77,4 +88,11 @@ teardown() { assert_failure assert_line --index 1 "❌ ERROR: unknown option" +} + +@test "failed: albumlist not found" { + run main + + assert_failure + assert_line --index 0 "❌ ERROR: file albumlist does not exists" } \ No newline at end of file diff --git a/tests/test.conf b/tests/test.conf index a169f04..f28ad19 100644 --- a/tests/test.conf +++ b/tests/test.conf @@ -1,2 +1 @@ -MUSIC_PATHES=("build/tests/music") -LIB_PATH="src/lib" \ No newline at end of file +MUSIC_PATHES=("build/tests/music") \ No newline at end of file -- 2.47.3