unset ENCODE_LOG
}
+# bats test_tags=albentohandy:check_programs
@test "failed: rsync not found" {
command() {
[ "$2" == "rsync" ] && return 1
assert_line --index 0 "❌ ERROR: command rsync not found"
}
+# bats test_tags=albentohandy:load_config
@test "failed: missing albumtohandy.conf" {
CONFIG_FILE="build/tests/nothing.conf"
assert_line --index 0 "❌ ERROR: missing build/tests/nothing.conf"
}
+# bats test_tags=albentohandy:load_config
@test "failed: missing MUSIC_PATH" {
CONFIG_FILE="build/tests/albentohandy.conf"
echo "" > "$CONFIG_FILE"
assert_line --index 0 "❌ ERROR: missing MUSIC_PATH in build/tests/albentohandy.conf"
}
+# bats test_tags=albentohandy:load_config
@test "failed: directory MUSIC_PATH does not exists" {
CONFIG_FILE="build/tests/albentohandy.conf"
echo "MUSIC_PATH=build/tests/not_exists" > "$CONFIG_FILE"
assert_line --index 0 "❌ ERROR: directory build/tests/not_exists does not exists"
}
+# bats test_tags=albentohandy:load_library,albentohandy:options
@test "failed: lib vorbis.sh not found" {
LIB_PATH="build/tests/lib"
assert_line --index 0 "❌ ERROR: lib build/tests/lib/vorbis.sh not found"
}
+# bats test_tags=albentohandy:load_library,albentohandy:options
@test "failed: lib mp3.sh not found" {
LIB_PATH="build/tests/lib"
assert_line --index 0 "❌ ERROR: lib build/tests/lib/mp3.sh not found"
}
+# bats test_tags=albentohandy:load_library,albentohandy:options
@test "failed: lib flac.sh not found" {
LIB_PATH="build/tests/lib"
assert_line --index 0 "❌ ERROR: lib build/tests/lib/flac.sh not found"
}
+# bats test_tags=albentohandy:load_library,albentohandy:options
@test "failed: lib opus.sh not found" {
LIB_PATH="build/tests/lib"
assert_line --index 0 "❌ ERROR: lib build/tests/lib/opus.sh not found"
}
+# bats test_tags=albentohandy:options
@test "failed: unknown option" {
run main -x
assert_line --index 1 "❌ ERROR: unknown option"
}
+# bats test_tags=albentohandy:load_library
@test "failed: could not load library" {
MUSIC_PATH="build/tests/music"
OUTPUT_PATH="build/tests/output"
assert_line --index 0 "❌ ERROR: could not load library src/lib/vorbis.sh"
}
+# bats test_tags=albentohandy:input
@test "failed: albumlist not found" {
run main
assert_line --index 0 "❌ ERROR: file albumlist does not exists"
}
+# bats test_tags=albentohandy:input
@test "failed: input file asdf not found" {
run main -i "asdf"
assert_line --index 0 "❌ ERROR: file asdf does not exists"
}
+# bats test_tags=albentohandy:output
@test "success: create output path" {
make_symlinks_to_work() {
:
[ -d "build/tests/output" ]
}
+# bats test_tags=albentohandy:input
@test "failed: directory build/tests/music/Alben/Artist2 does not exists" {
echo "Alben/Artist2" > "build/tests/albumlist"
assert_output --partial "build/tests/music/Alben/Artist2 does not exists"
}
+# bats test_tags=albentohandy:copy
@test "success: create symlink for Alben/Artist1/file.flac" {
cleanup_flac() {
:
[ -h "build/tests/output/Artist1/file.flac" ]
}
+# bats test_tags=albentohandy:copy
@test "failed: create symlink for Alben/Artist1/file.flac" {
cp() {
return 1
assert_line --index 0 "❌ ERROR: could not create symlinks for Alben/Artist1"
}
+# bats test_tags=albentohandy:copy
@test "success: copy cover.jpg for Alben/Artist1" {
cleanup_cover() {
:
[ -f "build/tests/output/Artist1/cover.jpg" ]
}
+# bats test_tags=albentohandy:copy
@test "failed: copy cover.jpg for Alben/Artist1" {
rsync() {
return 1
assert_line --index 0 "❌ ERROR: could not copy cover.jpg for Alben/Artist1"
}
+# bats test_tags=albentohandy:encode
@test "success: call encode" {
ENCODE_COUNT=1
assert_equal "$(awk 'NR==2 {print; exit}' "$ENCODE_LOG")" "build/tests/output"
}
+# bats test_tags=albentohandy:encode
@test "failed: could not encode" {
encode() {
return 1
assert_line --index 0 "❌ ERROR: could not encode build/tests/output"
}
+# bats test_tags=albentohandy:cleanup
@test "success: cleanup cover" {
mkdir --parents "build/tests/output/Artist1/"
echo "metadatacover" > "build/tests/output/Artist1/cover.txt"
[ ! -f "build/tests/output/Artist1/cover.jpg" ]
}
+# bats test_tags=albentohandy:cleanup
@test "failed: cleanup cover" {
cleanup_cover() {
return 1
assert_line --index 0 "❌ ERROR: could not cleanup cover"
}
+# bats test_tags=albentohandy:cleanup
@test "success: cleanup flac" {
run main -i "build/tests/albumlist"
[ ! -f "build/tests/output/Artist1/file.flac" ]
}
+# bats test_tags=albentohandy:cleanup
@test "success: not cleanup flac with flac lib" {
run main -i "build/tests/albumlist" -f
[ -f "build/tests/output/Artist1/file.flac" ]
}
+# bats test_tags=albentohandy:cleanup
@test "failed: could not cleanup flac" {
cleanup_flac() {
return 1