generated from john/python-template
@@ -5,6 +5,7 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from sqlalchemy import text
|
||||
|
||||
from transcription.config import Settings
|
||||
from transcription.db.models import MaintenanceJobType
|
||||
@@ -57,3 +58,18 @@ async def test_process_next_queued_run_persists_terminal_result(
|
||||
assert updated.summary == "Synthetic success"
|
||||
assert updated.log_path is not None
|
||||
assert (settings.log_dir / Path(updated.log_path)).is_file()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_runs_recreates_missing_table(default_session_factory, default_settings):
|
||||
service = MaintenanceService(session_factory=default_session_factory, settings=default_settings)
|
||||
async with default_session_factory() as session:
|
||||
await session.exec(text("DROP TABLE maintenance_run"))
|
||||
await session.commit()
|
||||
|
||||
runs = await service.list_runs(limit=10)
|
||||
assert runs == []
|
||||
|
||||
created = await service.enqueue_run(job_type=MaintenanceJobType.BACKUP, triggered_by="test")
|
||||
listed = await service.list_runs(limit=10)
|
||||
assert any(run.id == created.id for run in listed)
|
||||
|
||||
Reference in New Issue
Block a user