"""Shared fixtures for the checkpoint test suite."""

from collections.abc import Iterator
from pathlib import Path

import pygit2
import pytest

from attractor.checkpoint import Author, BranchStore


@pytest.fixture()
def repo(tmp_path: Path) -> pygit2.Repository:
    """Initialise a fresh non-bare repo for one test.

    We use a non-bare repo even though we never check anything out —
    pygit2's bare-repo path is subtly different (no `workdir`,
    different defaults) and the engine always runs against work
    trees, so non-bare is the realistic baseline.
    """
    return pygit2.init_repository(str(tmp_path / "repo"), bare=False)


@pytest.fixture()
def engine_author() -> Author:
    """`Author()` with no user configured — the §7.3 case A scenario."""
    return Author()


@pytest.fixture()
def user_author() -> Author:
    """`Author` with a configured user — the §7.3 case B scenario."""
    return Author(user_name="Test User", user_email="user@example.com")


@pytest.fixture()
def store(
    repo: pygit2.Repository, engine_author: Author
) -> Iterator[BranchStore]:
    """A default engine-only BranchStore bound to a fresh repo."""
    yield BranchStore(repo, engine_author)
