51 lines
1.6 KiB
Bash
Executable File
51 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Simple test runner for jeannie modules
|
|
|
|
GREEN='\033[0;32m'
|
|
RED='\033[0;31m'
|
|
NC='\033[0m' # No Color
|
|
|
|
PASSED=0
|
|
FAILED=0
|
|
|
|
run_test() {
|
|
local test_name="$1"
|
|
local test_cmd="$2"
|
|
echo -n "Running $test_name... "
|
|
if eval "$test_cmd"; then
|
|
echo -e "${GREEN}PASS${NC}"
|
|
((PASSED++))
|
|
else
|
|
echo -e "${RED}FAIL${NC}"
|
|
((FAILED++))
|
|
fi
|
|
}
|
|
|
|
# Source modules to be tested
|
|
# shellcheck disable=SC1091
|
|
source /home/jv/my-homelab-configs/lib/jeannie/core.sh
|
|
# shellcheck disable=SC1091
|
|
source /home/jv/my-homelab-configs/lib/jeannie/env.sh
|
|
|
|
# Test Core: truthy (returns 0 for true, 1 for false)
|
|
run_test "Core: truthy(true)" "truthy 'true'"
|
|
run_test "Core: truthy(1)" "truthy '1'"
|
|
run_test "Core: truthy(yes)" "truthy 'yes'"
|
|
run_test "Core: truthy(on)" "truthy 'on'"
|
|
run_test "Core: truthy(TRUE)" "truthy 'TRUE'"
|
|
run_test "Core: truthy(false)" "! truthy 'false'"
|
|
run_test "Core: truthy(empty)" "! truthy ''"
|
|
run_test "Core: truthy(unknown)" "! truthy 'maybe'"
|
|
|
|
# Test Core: disabled_value (returns 0 for disabled, 1 for enabled)
|
|
run_test "Core: disabled_value(false)" "disabled_value 'false'"
|
|
run_test "Core: disabled_value(0)" "disabled_value '0'"
|
|
run_test "Core: disabled_value(no)" "disabled_value 'no'"
|
|
run_test "Core: disabled_value(off)" "disabled_value 'off'"
|
|
run_test "Core: disabled_value(disabled)" "disabled_value 'disabled'"
|
|
run_test "Core: disabled_value(true)" "! disabled_value 'true'"
|
|
run_test "Core: disabled_value(1)" "! disabled_value '1'"
|
|
|
|
echo -e "\nResults: ${GREEN}$PASSED passed${NC}, ${RED}$FAILED failed${NC}"
|
|
[[ $FAILED -eq 0 ]]
|