]> gitweb.hhaalo.de Git - albentohandy.git/commitdiff
add tests for check rsync command
authorBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 07:10:10 +0000 (09:10 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Fri, 25 Sep 2026 07:10:10 +0000 (09:10 +0200)
src/albentohandy [new file with mode: 0755]
tests/albentohandy.bats [new file with mode: 0755]

diff --git a/src/albentohandy b/src/albentohandy
new file mode 100755 (executable)
index 0000000..ae8107f
--- /dev/null
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+errlog()
+{
+       local lastexit=$?
+       local msg="$1"
+
+       echo "❌ ERROR: $msg"
+       return $lastexit
+}
+
+main()
+{
+       command -v rsync > /dev/null \
+               || errlog "command rsync not found" \
+               || return $?
+}
+
+[ "$TEST_MODE" == "ON" ] && return 0
+main "$@"
\ No newline at end of file
diff --git a/tests/albentohandy.bats b/tests/albentohandy.bats
new file mode 100755 (executable)
index 0000000..7180ddd
--- /dev/null
@@ -0,0 +1,23 @@
+#!/usr/bin/bats
+
+setup() {
+       bats_load_library 'bats-support'
+       bats_load_library 'bats-assert'
+       export TEST_MODE="ON"
+       source src/albentohandy
+}
+
+teardown() {
+       unset TEST_MODE
+}
+
+@test "failed: rsync not found" {
+       command() {
+               [ "$2" == "rsync" ] && return 1
+       }
+
+       run main
+
+       assert_failure
+       assert_line --index 0 "❌ ERROR: command rsync not found"
+}
\ No newline at end of file