]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add flac program check
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 14:38:17 +0000 (16:38 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 14:39:25 +0000 (16:39 +0200)
src/lib/flac.sh
tests/flac.bats [new file with mode: 0755]

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..c0fdd805783277bca2531737a4520dd7cd537dbf 100644 (file)
@@ -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 (executable)
index 0000000..a86e0bc
--- /dev/null
@@ -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