mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
fix(project): include default_branch in project list summary response
This commit is contained in:
@@ -64,6 +64,7 @@ class ProjectSummaryResponse(BaseModel):
|
||||
name: str
|
||||
slug: str
|
||||
git_url: str
|
||||
default_branch: str
|
||||
assigned_cell: Team
|
||||
is_active: bool
|
||||
has_workspace: bool = False
|
||||
@@ -176,11 +177,13 @@ def project_to_response(project: "ProjectTable") -> ProjectResponse:
|
||||
|
||||
def project_to_summary(project: "ProjectTable") -> ProjectSummaryResponse:
|
||||
"""Convert a ProjectTable to ProjectSummaryResponse."""
|
||||
default_branch = project.default_branch
|
||||
return ProjectSummaryResponse(
|
||||
id=typing_cast("UUID", project.id),
|
||||
name=str(project.name),
|
||||
slug=str(project.slug),
|
||||
git_url=str(project.git_url),
|
||||
default_branch=str(default_branch) if default_branch else "main",
|
||||
assigned_cell=project.assigned_cell,
|
||||
is_active=bool(project.is_active),
|
||||
has_workspace=bool(project.workspace_path),
|
||||
|
||||
@@ -156,6 +156,22 @@ async def test_list_projects_filter_by_cell(
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_projects_includes_default_branch(
|
||||
project_client: AsyncClient,
|
||||
) -> None:
|
||||
payload = _payload()
|
||||
payload["default_branch"] = "master"
|
||||
create = await project_client.post("/api/projects", json=payload, headers=_HDR)
|
||||
assert create.status_code == HTTPStatus.CREATED
|
||||
|
||||
response = await project_client.get("/api/projects", headers=_HDR)
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
listed = {p["slug"]: p for p in response.json()}
|
||||
assert payload["slug"] in listed
|
||||
assert listed[payload["slug"]]["default_branch"] == "master"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_get_project_by_slug_not_found(project_client: AsyncClient) -> None:
|
||||
response = await project_client.get(
|
||||
|
||||
Reference in New Issue
Block a user