Files
xiaoxia-saas/tests/unit/test_release_scripts.py
T
Xiaoxia AI 786a7c30fc
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 11s
Deploy / Deploy Staging (push) Successful in 14s
Deploy / Deploy Production (push) Has been skipped
chore(release): provision separated production infrastructure
2026-06-21 15:35:09 +08:00

46 lines
1.7 KiB
Python

from pathlib import Path
def test_restore_postgres_plan_is_non_destructive():
script = Path("scripts/restore_postgres_plan.sh").read_text(encoding="utf-8")
executable_prefix = script.split("cat <<EOF", 1)[0]
assert "pg_restore" in script
assert "This script intentionally does not execute restore automatically." in script
assert "pg_restore" not in executable_prefix
def test_production_infra_uses_separate_containers_and_ports():
compose = Path("infra/docker/infra-production.yml").read_text(encoding="utf-8")
assert "name: xiaoxia-production" in compose
assert "container_name: xiaoxia-postgres-production" in compose
assert "container_name: xiaoxia-redis-production" in compose
assert "${POSTGRES_PORT:-5433}:5432" in compose
assert "${REDIS_PORT:-6380}:6379" in compose
assert "postgres_data:" not in compose
assert "redis_data:" not in compose
def test_init_production_env_is_non_deploying_and_separated():
script = Path("scripts/init_production_env.sh").read_text(encoding="utf-8")
assert "APP_ENV=production" in script
assert "ENVIRONMENT=production" in script
assert "xiaoxia-postgres-production" in script
assert "xiaoxia-redis-production" in script
assert "GENERATED_FILES_HOST_DIR=$GENERATED_DIR" in script
assert "ENABLE_EMAIL_DELIVERY=false" in script
assert "docker compose" not in script
assert "docker run" not in script
def test_backup_postgres_writes_manifest_and_version():
script = Path("scripts/backup_postgres.sh").read_text(encoding="utf-8")
assert "pg_dump" in script
assert "alembic_version.txt" in script
assert "manifest.txt" in script
assert "test -s" not in script
assert 'if [ ! -s "$DUMP_PATH" ]' in script