Files
sethLabels/tests-impl/test-deps-debian.bats
T
2026-04-29 10:28:55 -04:00

64 lines
1.9 KiB
Bash

#!/usr/bin/env bats
# Tests for scripts/lib/deps-debian.sh
setup() {
REPO_ROOT="$(git rev-parse --show-toplevel)"
SCRIPT="$REPO_ROOT/scripts/lib/deps-debian.sh"
}
@test "script exists and is executable" {
[ -x "$SCRIPT" ]
}
@test "sourceable: exposes SETHLABELS_DEPS array" {
source "$SCRIPT"
[ "${#SETHLABELS_DEPS[@]}" -gt 5 ]
}
@test "SETHLABELS_DEPS contains core build tools" {
source "$SCRIPT"
[[ " ${SETHLABELS_DEPS[*]} " == *" cmake "* ]]
[[ " ${SETHLABELS_DEPS[*]} " == *" ninja-build "* ]]
[[ " ${SETHLABELS_DEPS[*]} " == *" build-essential "* ]]
}
@test "SETHLABELS_DEPS contains Qt6 libraries" {
source "$SCRIPT"
[[ " ${SETHLABELS_DEPS[*]} " == *" qt6-base-dev "* ]]
[[ " ${SETHLABELS_DEPS[*]} " == *" qt6-svg-dev "* ]]
[[ " ${SETHLABELS_DEPS[*]} " == *" qt6-tools-dev "* ]]
}
@test "SETHLABELS_DEPS contains barcode + zlib deps" {
source "$SCRIPT"
[[ " ${SETHLABELS_DEPS[*]} " == *" zlib1g-dev "* ]]
[[ " ${SETHLABELS_DEPS[*]} " == *" libqrencode-dev "* ]]
[[ " ${SETHLABELS_DEPS[*]} " == *" libzint-dev "* ]]
}
@test "SETHLABELS_DEPS contains packaging tools" {
source "$SCRIPT"
[[ " ${SETHLABELS_DEPS[*]} " == *" dpkg-dev "* ]]
[[ " ${SETHLABELS_DEPS[*]} " == *" fakeroot "* ]]
[[ " ${SETHLABELS_DEPS[*]} " == *" wget "* ]]
}
@test "executed: prints status and exits 0 (when all installed) OR 1 with apt-install hint" {
run "$SCRIPT"
if [ "$status" -eq 0 ]; then
[[ "$output" == *"All build dependencies present"* ]]
else
[[ "$output" == *"sudo apt install"* ]]
fi
}
@test "executed: warns if not on Debian/Ubuntu" {
# Simulate non-Debian by overriding /etc/os-release path via env var
if [ -f /etc/os-release ] && grep -qE '^ID=(debian|ubuntu)' /etc/os-release; then
skip "currently on Debian/Ubuntu — non-Debian path covered by source review"
fi
run "$SCRIPT"
[[ "$output" == *"Debian"* || "$output" == *"Ubuntu"* ]]
}