mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
fix(project): default_branch defaults to master across the API create path
The request and service models defaulted default_branch to "main" and the response converters fell back to "main", so omitting the field on the create route persisted "main" instead of the DB column default of master. Flip every default_branch default and fallback to master.
This commit is contained in:
@@ -156,6 +156,29 @@ async def test_list_projects_filter_by_cell(
|
||||
assert response.status_code == HTTPStatus.OK
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_create_project_omitting_default_branch_yields_master(
|
||||
project_client: AsyncClient,
|
||||
) -> None:
|
||||
"""Omitting ``default_branch`` on the create route resolves to ``master``.
|
||||
|
||||
Exercises the real API create path: ``ProjectCreateRequest`` (field
|
||||
omitted) -> route ``create_project`` -> ``ProjectCreate`` -> service
|
||||
``create`` -> ``ProjectTable`` -> ``project_to_response``. None of these
|
||||
must inject the legacy ``main`` default.
|
||||
"""
|
||||
payload = _payload()
|
||||
del payload["default_branch"]
|
||||
|
||||
response = await project_client.post("/api/projects", json=payload, headers=_HDR)
|
||||
assert response.status_code == HTTPStatus.CREATED
|
||||
assert response.json()["default_branch"] == "master"
|
||||
|
||||
fetched = await project_client.get(f"/api/projects/{payload['slug']}", headers=_HDR)
|
||||
assert fetched.status_code == HTTPStatus.OK
|
||||
assert fetched.json()["default_branch"] == "master"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_list_projects_includes_default_branch(
|
||||
project_client: AsyncClient,
|
||||
|
||||
Reference in New Issue
Block a user