"""
Tests API logs Uvicorn.
"""

from pricewatch.app.api.main import list_uvicorn_logs


def test_list_uvicorn_logs_reads_file(monkeypatch, tmp_path):
    log_file = tmp_path / "uvicorn.log"
    log_file.write_text("ligne-1\nligne-2\n", encoding="utf-8")

    monkeypatch.setattr("pricewatch.app.api.main.UVICORN_LOG_PATH", log_file)

    response = list_uvicorn_logs(limit=1)
    assert len(response) == 1
    assert response[0].line == "ligne-2"
