test: cover manager behavior without live Gitea

This commit is contained in:
2026-05-06 15:24:56 +08:00
parent ba2c9d9f88
commit bd24a18c18
5 changed files with 518 additions and 0 deletions

30
tests/conftest.py Normal file
View File

@@ -0,0 +1,30 @@
from __future__ import annotations
from pathlib import Path
import pytest
from agent_gitea.config import AppConfig
from agent_gitea.db import Database
def make_config(tmp_path: Path, **overrides: object) -> AppConfig:
data = {
"gitea": {"base_url": "https://gitea.test", "token_env": "GITEA_TOKEN"},
"database_path": tmp_path / "state.sqlite3",
"scheduler": {"interval_seconds": 1, "concurrency": 1, "lease_seconds": 60},
"workspace": {"root": tmp_path / "workspaces", "cleanup_on_success": False},
"agents": {
"implementer": {"command": ["implementer", "{prompt_path}"]},
"reviewer": {"command": ["reviewer", "{prompt_path}"]},
},
}
data.update(overrides)
return AppConfig.model_validate(data)
@pytest.fixture
def db(tmp_path: Path) -> Database:
database = Database(tmp_path / "state.sqlite3")
database.migrate()
return database