- Create test_helper/common.bash with shared utilities - Add unit tests for firewall configuration functions - Add unit tests for build script functions - Establish testing patterns for TDD approach This provides the foundation for 100% test coverage. 💘 Generated with Crush Assisted-by: GLM-4.6 via Crush <crush@charm.land>
38 lines
925 B
Bash
38 lines
925 B
Bash
#!/usr/bin/env bats
|
|
# Test helper setup for bats-core
|
|
|
|
# Load bats support libraries if available
|
|
if [[ -f "/usr/lib/bats-core/bats-support/load.bash" ]]; then
|
|
load '/usr/lib/bats-core/bats-support/load'
|
|
load '/usr/lib/bats-core/bats-assert/load'
|
|
load '/usr/lib/bats-core/bats-file/load'
|
|
fi
|
|
|
|
# Common test variables
|
|
readonly TEST_TEMP_DIR=$(mktemp -d)
|
|
readonly PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
|
|
# Cleanup function
|
|
cleanup() {
|
|
rm -rf "$TEST_TEMP_DIR"
|
|
}
|
|
|
|
# Set up trap for cleanup
|
|
trap cleanup EXIT
|
|
|
|
# Common helper functions
|
|
create_test_wg_config() {
|
|
local config_file="$1"
|
|
cat > "$config_file" << EOF
|
|
[Interface]
|
|
PrivateKey = testPrivateKey1234567890abcdefghijklmnopqrstuvwxyz
|
|
Address = 10.0.0.2/24
|
|
DNS = 1.1.1.1
|
|
|
|
[Peer]
|
|
PublicKey = testPublicKey1234567890abcdefghijklmnopqrstuvwxyz
|
|
Endpoint = 192.168.1.100:51820
|
|
AllowedIPs = 0.0.0.0/0
|
|
PersistentKeepalive = 25
|
|
EOF
|
|
} |