mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-06 12:39:35 +02:00
47 lines
1.5 KiB
Bash
47 lines
1.5 KiB
Bash
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
source "$(dirname "$0")/base-test.sh"
|
|
|
|
test_tmp=$(mktemp -d)
|
|
trap 'rm -rf "$test_tmp"' EXIT
|
|
|
|
test_root="$test_tmp/omarchy"
|
|
test_home="$test_tmp/home"
|
|
mkdir -p "$test_root/migrations" "$test_home"
|
|
|
|
cat >"$test_root/migrations/100-migration.sh" <<'SH'
|
|
echo migration >>"$TEST_CALLS"
|
|
SH
|
|
|
|
run_migrate() {
|
|
HOME="$test_home" \
|
|
OMARCHY_PATH="$test_root" \
|
|
TEST_CALLS="$test_tmp/calls" \
|
|
"$ROOT/bin/omarchy-migrate" "$@"
|
|
}
|
|
|
|
: >"$test_tmp/calls"
|
|
run_migrate >"$test_tmp/migrate.out"
|
|
[[ $(sed -n '1p' "$test_tmp/calls") == "migration" ]] || fail "omarchy-migrate runs pending migrations"
|
|
pass "omarchy-migrate runs migrations without force"
|
|
|
|
rm -rf "$test_home/.local/state/omarchy/migrations"
|
|
run_migrate --pending >"$test_tmp/pending.out"
|
|
grep -q '^100-migration\.sh$' "$test_tmp/pending.out" || fail "omarchy-migrate --pending lists pending migrations"
|
|
pass "omarchy-migrate --pending lists pending migrations"
|
|
|
|
run_migrate >"$test_tmp/migrate-second.out"
|
|
if run_migrate --pending >"$test_tmp/not-pending.out"; then
|
|
fail "omarchy-migrate --pending exits non-zero without pending migrations"
|
|
fi
|
|
[[ ! -s $test_tmp/not-pending.out ]] || fail "omarchy-migrate --pending stays quiet without pending migrations"
|
|
pass "omarchy-migrate --pending reports no pending migrations"
|
|
|
|
if run_migrate --force >"$test_tmp/force.out" 2>&1; then
|
|
fail "omarchy-migrate rejects obsolete --force option"
|
|
fi
|
|
grep -q 'Unknown option: --force' "$test_tmp/force.out" || fail "omarchy-migrate reports obsolete --force option"
|
|
pass "omarchy-migrate no longer needs --force"
|