fix: handle nullable Gitea issue metadata (#50)
CI / lint (pull_request) Successful in 8s
CI / build-frontend (pull_request) Successful in 4s

This commit is contained in:
timmy committed 2026-08-05 23:18:32 +00:00
1 parent 352d70e859
commit e8b5fd31a5
3 files changed
+43 -18

No files matched your search

+33 -1
View File
@@ -1,4 +1,5 @@
import asyncio
import json
import pytest
@@ -30,4 +31,35 @@ async def test_context_returns_fallback_when_gitea_exceeds_deadline(monkeypatch)
assert response.headers["retry-after"] == "1"
assert b'"repos":[]' in response.body
assert b'"error":"Gitea context request timed out after 0.01s"' in response.body
assert cancelled.is_set()
assert cancelled.is_set()
@pytest.mark.anyio
async def test_context_normalizes_nullable_issue_collections(monkeypatch):
async def user():
return {"id": 1, "login": "timmy"}
async def empty_collection():
return []
async def issue_collection():
return [{
"id": 50,
"number": 50,
"title": "Nullable metadata",
"state": "open",
"labels": None,
"assignees": None,
"html_url": "https://forge.example/issues/50",
}]
monkeypatch.setattr(main, "current_user", user)
monkeypatch.setattr(main, "repos", empty_collection)
monkeypatch.setattr(main, "issues", issue_collection)
monkeypatch.setattr(main, "pull_requests", empty_collection)
response = await main.context()
issue = json.loads(response.body)["issues"][0]
assert issue["labels"] == []
assert issue["assignees"] == []