mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2026-06-19 07:36:59 +00:00
47 lines
1.3 KiB
Bash
47 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
INSTALL_SCRIPT="$ROOT_DIR/install.sh"
|
|
|
|
assert_contains() {
|
|
local haystack="$1"
|
|
local needle="$2"
|
|
local message="$3"
|
|
|
|
if [[ "$haystack" != *"$needle"* ]]; then
|
|
echo "not ok - $message"
|
|
echo "expected to find: $needle"
|
|
echo "actual output:"
|
|
echo "$haystack"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
test_openwrt_with_apk_is_not_detected_as_openrc() {
|
|
local sandbox output
|
|
sandbox="$(mktemp -d)"
|
|
trap 'rm -rf "$sandbox"' RETURN
|
|
|
|
mkdir -p "$sandbox/bin" "$sandbox/etc" "$sandbox/proc/1" "$sandbox/sbin"
|
|
cat > "$sandbox/etc/os-release" <<'EOF'
|
|
NAME="OpenWrt"
|
|
ID="openwrt"
|
|
VERSION_ID="25.10"
|
|
EOF
|
|
: > "$sandbox/etc/openwrt_release"
|
|
: > "$sandbox/proc/cpuinfo"
|
|
: > "$sandbox/proc/1/cgroup"
|
|
ln -s /bin/true "$sandbox/bin/apk"
|
|
|
|
output="$(NGINX_UI_INSTALL_TESTING=1 "$INSTALL_SCRIPT" __test_detect "$sandbox" 2>&1)"
|
|
|
|
assert_contains "$output" "PACKAGE_MANAGEMENT_INSTALL=apk add --no-cache" "OpenWrt 25 should use apk for packages"
|
|
assert_contains "$output" "SERVICE_TYPE=openwrt" "OpenWrt 25 should use OpenWrt service type"
|
|
}
|
|
|
|
test_openwrt_with_apk_is_not_detected_as_openrc
|
|
|
|
echo "ok - install.sh detects OpenWrt 25 apk as openwrt"
|