45 lines
1.3 KiB
Bash
45 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
set -u -o pipefail
|
|
|
|
TEST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
test_dir="$(mktemp -d)"
|
|
trap 'rm -rf "$test_dir"' EXIT
|
|
|
|
source "${TEST_ROOT}/tests/testlib.sh"
|
|
source "${TEST_ROOT}/inc/header-info.inc"
|
|
|
|
pveversion() {
|
|
printf '%s\n' 'pve-manager/9.2.4/5e5ae681198514d4 (running kernel: 7.0.14-5-pve)'
|
|
}
|
|
|
|
cat >"${test_dir}/corosync.conf" <<'EOF'
|
|
totem {
|
|
version: 2
|
|
cluster_name: production-cluster
|
|
}
|
|
EOF
|
|
|
|
TAPM_LOAD_HEADER_INFO "${test_dir}/corosync.conf"
|
|
assert_equal '9.2.4' "$TAPM_HEADER_PVE_VERSION" \
|
|
"header extracts the concise Proxmox VE version"
|
|
assert_equal 'production-cluster' "$TAPM_HEADER_CLUSTER" \
|
|
"header reads the local cluster name"
|
|
|
|
pveversion() {
|
|
printf '%s\n' 'pve-manager/10.0.0/changed'
|
|
}
|
|
TAPM_LOAD_HEADER_INFO "${test_dir}/corosync.conf"
|
|
assert_equal '9.2.4' "$TAPM_HEADER_PVE_VERSION" \
|
|
"header information is cached between menu redraws"
|
|
|
|
TAPM_HEADER_INFO_LOADED=0
|
|
TAPM_HEADER_PVE_VERSION='Unavailable'
|
|
TAPM_HEADER_CLUSTER='Standalone'
|
|
TAPM_LOAD_HEADER_INFO "${test_dir}/missing.conf"
|
|
assert_equal '10.0.0' "$TAPM_HEADER_PVE_VERSION" \
|
|
"header refresh reads the current Proxmox VE version"
|
|
assert_equal 'Standalone' "$TAPM_HEADER_CLUSTER" \
|
|
"host without corosync configuration is shown as standalone"
|
|
|
|
finish_tests
|