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

ops.pre_restore DELETED the ci-marker repo (diverged from backup state).
The orchestrator restored from the backup. This overlay ADDS: the marker repo returned
(sqlite3 was restored to the backed-up state). A no-op restore would leave the repo absent.
"""

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_restore_returns_marker_repo(live_app, meta):
    """The ci-marker repo returned after restore (sqlite3 reverted to backed-up state)."""
    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 absent after restore — restore did not revert the deletion "
        "(sqlite3 not restored to backed-up state)"
    )
