|| errlog "file $albumlist does not exists" \
|| return $?
- mkdir --parents "$OUTPUT_PATH"
- make_symlinks_to_work "$albumlist"
+ mkdir --parents "$OUTPUT_PATH" || return $?
+ make_symlinks_to_work "$albumlist" || return $?
+ encode "$OUTPUT_PATH"
}
[ "$TEST_MODE" == "ON" ] && return 0
export TEST_MODE="ON"
export CONFIG_FILE="tests/test.conf"
export LIB_PATH="src/lib"
+ export ENCODE_COUNT=0
+ export ENCODE_LOG="build/tests/encode.log"
source src/albentohandy
+ encode() {
+ ((ENCODE_COUNT--))
+ [ "$ENCODE_COUNT" -eq 0 ] || return 0
+ ((ENCODE_COUNT--))
+
+ {
+ printf "%s\n" "${#@}"
+ printf "%s\n" "$@"
+ } > "$ENCODE_LOG"
+ }
}
teardown() {
rm --recursive --force "build"
+ rm --force "$ENCODE_LOG"
unset TEST_MODE
unset CONFIG_FILE
unset LIB_PATH
+ unset ENCODE_COUNT
+ unset ENCODE_LOG
}
@test "failed: rsync not found" {
assert_failure
assert_line --index 0 "❌ ERROR: could not copy cover.jpg for Alben/Artist1"
+}
+
+@test "success: call encode" {
+ ENCODE_COUNT=1
+
+ run main -i "build/tests/albumlist"
+
+ assert_success
+ assert_equal "$(awk 'NR==1 {print; exit}' "$ENCODE_LOG")" "1"
+ assert_equal "$(awk 'NR==2 {print; exit}' "$ENCODE_LOG")" "build/tests/output"
}
\ No newline at end of file