From ce3a75419ff0136b93960599613e46df5b307a4d Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Fri, 25 Sep 2026 16:38:17 +0200 Subject: [PATCH] add flac program check --- src/lib/flac.sh | 19 +++++++++++++++++++ tests/flac.bats | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 tests/flac.bats 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 -- 2.47.3