]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add tests for copy cover jpg
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 10:11:09 +0000 (12:11 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 10:11:09 +0000 (12:11 +0200)
src/albentohandy
tests/albentohandy.bats

index e9bd782d283e02708e543f5c10f82d33d75a30f8..2949a7060de46b3875a2ee65deee2eab823c3704 100755 (executable)
@@ -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
 }
 
index 88a6d69cc8d13350279f6a7a96652d72d722568b..fdf947c5698d166d5debb7ba5f0bea1c5de01dd7 100755 (executable)
@@ -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