From 1170b651ce5553db28dbe8a45a60c903651587c3 Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 12:11:09 +0200 Subject: [PATCH] add tests for copy cover jpg --- src/albentohandy | 11 +++++++++++ tests/albentohandy.bats | 29 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/albentohandy b/src/albentohandy index e9bd782..2949a70 100755 --- a/src/albentohandy +++ b/src/albentohandy @@ -56,6 +56,17 @@ make_symlinks_to_work() "$OUTPUT_PATH" \ || errlog "could not create symlinks for $album" \ || return $? + rsync --recursive \ + --perms \ + --times \ + --group \ + --owner \ + --exclude="*.flac" \ + --include="cover.jpg" \ + "$MUSIC_PATH/$album" \ + "$OUTPUT_PATH" \ + || errlog "could not copy cover.jpg for $album" \ + || return $? done } diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index 88a6d69..fdf947c 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -156,4 +156,33 @@ teardown() { assert_failure assert_line --index 0 "❌ ERROR: could not create symlinks for Alben/Artist1" +} + +@test "success: copy cover.jpg for Alben/Artist1" { + mkdir --parents "build/tests/output" + mkdir --parents "build/tests/music/Alben/Artist1" + echo "testfile" > "build/tests/music/Alben/Artist1/file.flac" + echo "cover" > "build/tests/music/Alben/Artist1/cover.jpg" + + run main -i "build/tests/albumlist" + + assert_success + [ -h "build/tests/output/Artist1/file.flac" ] + [ ! -h "build/tests/output/Artist1/cover.jpg" ] + [ -f "build/tests/output/Artist1/cover.jpg" ] +} + +@test "failed: copy cover.jpg for Alben/Artist1" { + mkdir --parents "build/tests/output" + mkdir --parents "build/tests/music/Alben/Artist1" + echo "testfile" > "build/tests/music/Alben/Artist1/file.flac" + echo "cover" > "build/tests/music/Alben/Artist1/cover.jpg" + rsync() { + return 1 + } + + run main -i "build/tests/albumlist" + + assert_failure + assert_line --index 0 "❌ ERROR: could not copy cover.jpg for Alben/Artist1" } \ No newline at end of file -- 2.47.3