"""gitea — UPGRADE overlay (phase gtea).

ops.pre_upgrade ensured the ci-marker repo existed before the chaos redeploy.
The orchestrator performed the upgrade. This overlay ADDS: the marker repo survived.
"""

from __future__ import annotations

import os
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "..", "runner"))
from harness import generic  # noqa: E402

sys.path.insert(0, os.path.dirname(__file__))
from ops import admin_creds, marker_repo_exists  # noqa: E402


def test_upgrade_preserves_marker_repo(live_app, meta):
    """The ci-marker repo survived the upgrade to the PR head (data continuity)."""
    generic.assert_serving(live_app, meta)
    user, password = admin_creds(live_app)
    assert marker_repo_exists(live_app, user, password), (
        f"{live_app}: ci-marker repo did not survive the upgrade (sqlite3 data lost)"
    )
