]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add cleanup flac
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 11:25:17 +0000 (13:25 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 11:25:17 +0000 (13:25 +0200)
src/albentohandy
src/lib/flac.sh [new file with mode: 0644]
tests/albentohandy.bats

index 59728961ecf3696f06363d51fea3465c0bd3e00f..e315a16ee60b2da53b10876444d4f5f6f858e00d 100755 (executable)
@@ -75,6 +75,13 @@ cleanup_cover()
        find "$OUTPUT_PATH" -regex '.*cover\.\(txt\|jpg\)' -exec rm {} \;
 }
 
+cleanup_flac()
+{
+       local lib="$1"
+       [ "$lib" != "flac.sh" ] || return 0
+       find "$OUTPUT_PATH" -name '*.flac' -exec rm {} \;
+}
+
 main()
 {
        local albumlist="albumlist"
@@ -111,6 +118,9 @@ main()
        cleanup_cover \
                || errlog "could not cleanup cover" \
                || return $?
+       cleanup_flac "$lib" \
+               || errlog "could not cleanup flac" \
+               || return $?
 }
 
 [ "$TEST_MODE" == "ON" ] && return 0
diff --git a/src/lib/flac.sh b/src/lib/flac.sh
new file mode 100644 (file)
index 0000000..e69de29
index fc093ff4ad99b49537ea61c7a21b52b98741f859..bd1b907e0eb987048a4692a75600a7488da14538 100755 (executable)
@@ -170,6 +170,10 @@ teardown() {
 }
 
 @test "success: create symlink for Alben/Artist1/file.flac" {
+       cleanup_flac() {
+               :
+       }
+
        run main -i "build/tests/albumlist"
 
        assert_success
@@ -191,6 +195,9 @@ teardown() {
        cleanup_cover() {
                :
        }
+       cleanup_flac() {
+               :
+       }
 
        run main -i "build/tests/albumlist"
 
@@ -252,4 +259,29 @@ teardown() {
 
        assert_failure
        assert_line --index 0 "❌ ERROR: could not cleanup cover"
+}
+
+@test "success: cleanup flac" {
+       run main -i "build/tests/albumlist"
+
+       assert_success
+       [ ! -f "build/tests/output/Artist1/file.flac" ]
+}
+
+@test "success: not cleanup flac with flac lib" {
+       run main -i "build/tests/albumlist" -f
+
+       assert_success
+       [ -f "build/tests/output/Artist1/file.flac" ]
+}
+
+@test "failed: could not cleanup flac" {
+       cleanup_flac() {
+               return 1
+       }
+
+       run main -i "build/tests/albumlist" -f
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: could not cleanup flac"
 }
\ No newline at end of file