]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add symlink creation for output
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 09:51:05 +0000 (11:51 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 09:51:05 +0000 (11:51 +0200)
src/albentohandy
tests/albentohandy.bats

index 09aa89828478ea08d0a09ee04eeb2bc0f1d39b15..21848f01e774be532956b4fcc19ad386ac32af62 100755 (executable)
@@ -31,6 +31,10 @@ load_config()
        [ -n "$MUSIC_PATH" ] \
                || errlog "missing MUSIC_PATH in $CONFIG_FILE" \
                || return $?
+       [ -d "$MUSIC_PATH" ] \
+               || errlog "directory $MUSIC_PATH does not exists" \
+               || return $?
+       MUSIC_PATH=$(realpath "$MUSIC_PATH")
        LIB_PATH=${LIB_PATH:-"$scriptpath/lib"}
        OUTPUT_PATH=${OUTPUT_PATH:-"work.$$"}
 }
@@ -46,6 +50,10 @@ make_symlinks_to_work()
                [ -d "$MUSIC_PATH/$album" ] \
                        || errlog "directory $MUSIC_PATH/$album does not exists" \
                        || return $?
+               cp --recursive \
+                       --symbolic-link \
+                       "$MUSIC_PATH/$album" \
+                       "$OUTPUT_PATH"
        done
 }
 
index 8db31772e23c8e1086e955388e5737450daa4dc4..32ec11af9b494d611d342361237d91ed42151a5e 100755 (executable)
@@ -3,7 +3,7 @@
 setup() {
        bats_load_library 'bats-support'
        bats_load_library 'bats-assert'
-       mkdir --parents "build/tests"
+       mkdir --parents "build/tests/music"
        echo "Alben/Artist1" > "build/tests/albumlist"
        export TEST_MODE="ON"
        export CONFIG_FILE="tests/test.conf"
@@ -38,7 +38,7 @@ teardown() {
        assert_line --index 0 "❌ ERROR: missing build/tests/nothing.conf"
 }
 
-@test "failed: missing MUSIC_PATHES" {
+@test "failed: missing MUSIC_PATH" {
        CONFIG_FILE="build/tests/albentohandy.conf"
        echo "" > "$CONFIG_FILE"
 
@@ -48,6 +48,16 @@ teardown() {
        assert_line --index 0 "❌ ERROR: missing MUSIC_PATH in build/tests/albentohandy.conf"
 }
 
+@test "failed: directory MUSIC_PATH does not exists" {
+       CONFIG_FILE="build/tests/albentohandy.conf"
+       echo "MUSIC_PATH=build/tests/not_exists" > "$CONFIG_FILE"
+
+       run main
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: directory build/tests/not_exists does not exists"
+}
+
 @test "failed: lib vorbis.sh not found" {
        LIB_PATH="build/tests/lib"
 
@@ -120,5 +130,16 @@ teardown() {
        run main -i "build/tests/albumlist"
 
        assert_failure
-       assert_line --index 0 "❌ ERROR: directory build/tests/music/Alben/Artist1 does not exists"
+       assert_output --partial "build/tests/music/Alben/Artist1 does not exists"
+}
+
+@test "success: create symlink for Alben/Artist1/file.flac" {
+       mkdir --parents "build/tests/output"
+       mkdir --parents "build/tests/music/Alben/Artist1"
+       echo "testfile" > "build/tests/music/Alben/Artist1/file.flac"
+
+       run main -i "build/tests/albumlist"
+
+       assert_success
+       [ -h "build/tests/output/Artist1/file.flac" ]
 }
\ No newline at end of file