Files
runaway/tests/test_backup.bats
T
ruihan 25fac5f43f feat: tests, demo, JSON output, VPN kill-switch, more issue responses
- tests/: bats test suite for 8 modules (suppress, heal, firewall, detect,
  validate, colors, dscl, backup)
- demo: simulated full bypass flow for showcasing (no real changes)
- --json flag for report and audit commands (machine-readable output)
- vpn-kill: pf-based kill-switch that blocks MDM outside VPN tunnel
- vpn-kill-remove / vpn-kill-status: manage the kill-switch
- Responded to 5 more bypass-mdm issues (#135, #141, #150, #151, #154)
- CI now includes all new lib files in ShellCheck
- Bump 1.4.0 -> 1.5.0
2026-06-20 13:07:03 -03:00

41 lines
981 B
Bash

#!/usr/bin/env bats
# Tests for backup.sh - run with: bats tests/test_backup.bats
setup() {
load '../lib/colors.sh'
load '../lib/backup.sh'
SCRIPT_DIR=$(mktemp -d)
TEST_DIR=$(mktemp -d)
mkdir -p "$TEST_DIR/private/etc"
mkdir -p "$TEST_DIR/private/var/db/ConfigurationProfiles/Settings"
echo "test" > "$TEST_DIR/private/etc/hosts"
BACKUP_DIR="$SCRIPT_DIR/.unleash-backup"
}
teardown() {
rm -rf "$SCRIPT_DIR" "$TEST_DIR"
}
@test "backup_state creates backup directory" {
run backup_state "$TEST_DIR" 2>/dev/null || true
[ -d "$BACKUP_DIR" ]
}
@test "backup_state saves hosts file" {
run backup_state "$TEST_DIR" 2>/dev/null || true
[ -f "$BACKUP_DIR/hosts.backup" ]
run cat "$BACKUP_DIR/hosts.backup"
[ "$output" = "test" ]
}
@test "has_backup returns false initially" {
run has_backup
[ "$status" -eq 1 ]
}
@test "has_backup returns true after backup" {
backup_state "$TEST_DIR" 2>/dev/null || true
run has_backup
[ "$status" -eq 0 ]
}