30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from pathlib import Path
|
|
import tarfile
|
|
|
|
from alembic.config import Config
|
|
from alembic.script import ScriptDirectory
|
|
import yaml
|
|
|
|
from scripts.build_release import build_release
|
|
|
|
|
|
def test_migrations_have_one_head():
|
|
assert ScriptDirectory.from_config(Config("alembic.ini")).get_heads() == ["20260913_staff_concurrency"]
|
|
|
|
|
|
def test_release_contains_runtime_and_migrations_but_no_secrets(tmp_path):
|
|
path = build_release(tmp_path / "lottery.tar.gz")
|
|
with tarfile.open(path) as archive:
|
|
names = archive.getnames()
|
|
assert "main.py" in names and "Dockerfile" in names
|
|
assert "migrations/versions/20260913_staff_concurrency.py" in names
|
|
assert not any(".env" in name or ".history" in name or ".git/" in name or "__pycache__" in name for name in names)
|
|
|
|
|
|
def test_ci_requires_success_and_never_deploys_pull_requests():
|
|
config = yaml.safe_load(Path(".drone.yml").read_text(encoding="utf-8"))
|
|
deploy = config["steps"][-1]
|
|
assert deploy["when"] == {"branch": ["master"], "event": ["push"], "status": ["success"]}
|
|
assert not any("||" in command for step in config["steps"] for command in step["commands"])
|
|
assert {step["name"] for step in config["steps"]} >= {"checks", "postgres-tests", "package", "deploy"}
|