From: Bastian Dehn Date: Fri, 25 Sep 2026 07:10:10 +0000 (+0200) Subject: add tests for check rsync command X-Git-Tag: v1.0.0^2~7^2~38 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=7e14b4a530f7b7088067d630fe2c589fa04d0c07;p=albentohandy.git add tests for check rsync command --- diff --git a/src/albentohandy b/src/albentohandy new file mode 100755 index 0000000..ae8107f --- /dev/null +++ b/src/albentohandy @@ -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 index 0000000..7180ddd --- /dev/null +++ b/tests/albentohandy.bats @@ -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