From: Bastian Dehn Date: Fri, 25 Sep 2026 14:38:17 +0000 (+0200) Subject: add flac program check X-Git-Tag: v1.0.0^2~7^2~10 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=ce3a75419ff0136b93960599613e46df5b307a4d;p=albentohandy.git add flac program check --- diff --git a/src/lib/flac.sh b/src/lib/flac.sh index e69de29..c0fdd80 100644 --- a/src/lib/flac.sh +++ b/src/lib/flac.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +flac_errlog() +{ + local lastexit=$? + local msg="$1" + + echo "❌ ERROR: $msg" + return $lastexit +} + +flac_check_programs() +{ + command -v metaflac > /dev/null \ + || flac_errlog "command metaflac not found" \ + || return $? +} + +flac_check_programs || return $? \ No newline at end of file diff --git a/tests/flac.bats b/tests/flac.bats new file mode 100755 index 0000000..a86e0bc --- /dev/null +++ b/tests/flac.bats @@ -0,0 +1,19 @@ +#!/usr/bin/bats + +setup() { + bats_load_library 'bats-support' + bats_load_library 'bats-assert' + source "src/lib/flac.sh" +} + +# bats test_tag=flac:check_programs +@test "failed: check programs missing metaflac" { + command() { + [ "$2" != "metaflac" ] || return 1 + } + + run flac_check_programs + + assert_failure + assert_line --index 0 "❌ ERROR: command metaflac not found" +} \ No newline at end of file