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

ops.pre_backup ensured the ci-marker repo existed before the backup was taken.
The orchestrator performed the backup (generic tier asserted a snapshot artifact).
This overlay ADDS: the marker repo is present at backup time (backup captured real data).
"""

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_backup_captures_marker_repo(live_app, meta):
    """The ci-marker repo is present at backup time (backup captures the sqlite3 state)."""
    # backupbot cycles the gitea container during backup — wait for it to be back up.
    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 is not present at backup time (backup would capture empty state)"
    )
