Files
pokemon-inventory/scripts/verify-postgres-backup.test.sh
T
fragginwagon 73b4b9795e
Quality / test (push) Canceled after 0s
feat: verify postgres backups
2026-09-09 18:38:57 -04:00

22 lines
647 B
Bash
Executable File

#!/bin/sh
set -eu
script_dir=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
test_dir=$(mktemp -d)
trap 'rm -rf "$test_dir"' EXIT
printf '%s\n' 'fake dump' > "$test_dir/backup.dump"
mkdir -p "$test_dir/bin"
printf '%s\n' '#!/bin/sh' 'exit 0' > "$test_dir/bin/docker"
chmod +x "$test_dir/bin/docker"
PATH="$test_dir/bin:$PATH" BACKUP_FILE="$test_dir/backup.dump" \
sh "$script_dir/verify-postgres-backup.sh" >/dev/null
if BACKUP_FILE="$test_dir/missing.dump" sh "$script_dir/verify-postgres-backup.sh" >/dev/null 2>&1; then
printf '%s\n' 'Expected missing backup to fail.' >&2
exit 1
fi
printf '%s\n' 'verify-postgres-backup tests passed.'