From 51be1d5c9437a4ec8a9751ae0e0d0484a0b459dc Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 13:35:52 +0200 Subject: [PATCH] add bats test tags --- tests/albentohandy.bats | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index bd1b907..47513d2 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -36,6 +36,7 @@ teardown() { unset ENCODE_LOG } +# bats test_tags=albentohandy:check_programs @test "failed: rsync not found" { command() { [ "$2" == "rsync" ] && return 1 @@ -47,6 +48,7 @@ teardown() { assert_line --index 0 "❌ ERROR: command rsync not found" } +# bats test_tags=albentohandy:load_config @test "failed: missing albumtohandy.conf" { CONFIG_FILE="build/tests/nothing.conf" @@ -56,6 +58,7 @@ teardown() { assert_line --index 0 "❌ ERROR: missing build/tests/nothing.conf" } +# bats test_tags=albentohandy:load_config @test "failed: missing MUSIC_PATH" { CONFIG_FILE="build/tests/albentohandy.conf" echo "" > "$CONFIG_FILE" @@ -66,6 +69,7 @@ teardown() { assert_line --index 0 "❌ ERROR: missing MUSIC_PATH in build/tests/albentohandy.conf" } +# bats test_tags=albentohandy:load_config @test "failed: directory MUSIC_PATH does not exists" { CONFIG_FILE="build/tests/albentohandy.conf" echo "MUSIC_PATH=build/tests/not_exists" > "$CONFIG_FILE" @@ -76,6 +80,7 @@ teardown() { assert_line --index 0 "❌ ERROR: directory build/tests/not_exists does not exists" } +# bats test_tags=albentohandy:load_library,albentohandy:options @test "failed: lib vorbis.sh not found" { LIB_PATH="build/tests/lib" @@ -85,6 +90,7 @@ teardown() { assert_line --index 0 "❌ ERROR: lib build/tests/lib/vorbis.sh not found" } +# bats test_tags=albentohandy:load_library,albentohandy:options @test "failed: lib mp3.sh not found" { LIB_PATH="build/tests/lib" @@ -94,6 +100,7 @@ teardown() { assert_line --index 0 "❌ ERROR: lib build/tests/lib/mp3.sh not found" } +# bats test_tags=albentohandy:load_library,albentohandy:options @test "failed: lib flac.sh not found" { LIB_PATH="build/tests/lib" @@ -103,6 +110,7 @@ teardown() { assert_line --index 0 "❌ ERROR: lib build/tests/lib/flac.sh not found" } +# bats test_tags=albentohandy:load_library,albentohandy:options @test "failed: lib opus.sh not found" { LIB_PATH="build/tests/lib" @@ -112,6 +120,7 @@ teardown() { assert_line --index 0 "❌ ERROR: lib build/tests/lib/opus.sh not found" } +# bats test_tags=albentohandy:options @test "failed: unknown option" { run main -x @@ -119,6 +128,7 @@ teardown() { assert_line --index 1 "❌ ERROR: unknown option" } +# bats test_tags=albentohandy:load_library @test "failed: could not load library" { MUSIC_PATH="build/tests/music" OUTPUT_PATH="build/tests/output" @@ -135,6 +145,7 @@ teardown() { assert_line --index 0 "❌ ERROR: could not load library src/lib/vorbis.sh" } +# bats test_tags=albentohandy:input @test "failed: albumlist not found" { run main @@ -142,6 +153,7 @@ teardown() { assert_line --index 0 "❌ ERROR: file albumlist does not exists" } +# bats test_tags=albentohandy:input @test "failed: input file asdf not found" { run main -i "asdf" @@ -149,6 +161,7 @@ teardown() { assert_line --index 0 "❌ ERROR: file asdf does not exists" } +# bats test_tags=albentohandy:output @test "success: create output path" { make_symlinks_to_work() { : @@ -160,6 +173,7 @@ teardown() { [ -d "build/tests/output" ] } +# bats test_tags=albentohandy:input @test "failed: directory build/tests/music/Alben/Artist2 does not exists" { echo "Alben/Artist2" > "build/tests/albumlist" @@ -169,6 +183,7 @@ teardown() { assert_output --partial "build/tests/music/Alben/Artist2 does not exists" } +# bats test_tags=albentohandy:copy @test "success: create symlink for Alben/Artist1/file.flac" { cleanup_flac() { : @@ -180,6 +195,7 @@ teardown() { [ -h "build/tests/output/Artist1/file.flac" ] } +# bats test_tags=albentohandy:copy @test "failed: create symlink for Alben/Artist1/file.flac" { cp() { return 1 @@ -191,6 +207,7 @@ teardown() { assert_line --index 0 "❌ ERROR: could not create symlinks for Alben/Artist1" } +# bats test_tags=albentohandy:copy @test "success: copy cover.jpg for Alben/Artist1" { cleanup_cover() { : @@ -207,6 +224,7 @@ teardown() { [ -f "build/tests/output/Artist1/cover.jpg" ] } +# bats test_tags=albentohandy:copy @test "failed: copy cover.jpg for Alben/Artist1" { rsync() { return 1 @@ -218,6 +236,7 @@ teardown() { assert_line --index 0 "❌ ERROR: could not copy cover.jpg for Alben/Artist1" } +# bats test_tags=albentohandy:encode @test "success: call encode" { ENCODE_COUNT=1 @@ -228,6 +247,7 @@ teardown() { assert_equal "$(awk 'NR==2 {print; exit}' "$ENCODE_LOG")" "build/tests/output" } +# bats test_tags=albentohandy:encode @test "failed: could not encode" { encode() { return 1 @@ -239,6 +259,7 @@ teardown() { assert_line --index 0 "❌ ERROR: could not encode build/tests/output" } +# bats test_tags=albentohandy:cleanup @test "success: cleanup cover" { mkdir --parents "build/tests/output/Artist1/" echo "metadatacover" > "build/tests/output/Artist1/cover.txt" @@ -250,6 +271,7 @@ teardown() { [ ! -f "build/tests/output/Artist1/cover.jpg" ] } +# bats test_tags=albentohandy:cleanup @test "failed: cleanup cover" { cleanup_cover() { return 1 @@ -261,6 +283,7 @@ teardown() { assert_line --index 0 "❌ ERROR: could not cleanup cover" } +# bats test_tags=albentohandy:cleanup @test "success: cleanup flac" { run main -i "build/tests/albumlist" @@ -268,6 +291,7 @@ teardown() { [ ! -f "build/tests/output/Artist1/file.flac" ] } +# bats test_tags=albentohandy:cleanup @test "success: not cleanup flac with flac lib" { run main -i "build/tests/albumlist" -f @@ -275,6 +299,7 @@ teardown() { [ -f "build/tests/output/Artist1/file.flac" ] } +# bats test_tags=albentohandy:cleanup @test "failed: could not cleanup flac" { cleanup_flac() { return 1 -- 2.47.3