From c04aeaac09f2ecc97bf9dd8b9dff560ec6bb621b Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 11:51:05 +0200 Subject: [PATCH] add symlink creation for output --- src/albentohandy | 8 ++++++++ tests/albentohandy.bats | 27 ++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/albentohandy b/src/albentohandy index 09aa898..21848f0 100755 --- a/src/albentohandy +++ b/src/albentohandy @@ -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 } diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats index 8db3177..32ec11a 100755 --- a/tests/albentohandy.bats +++ b/tests/albentohandy.bats @@ -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 -- 2.47.3