mirror of
https://github.com/rennf93/roboco.git
synced 2026-08-03 07:23:24 +02:00
[F139] scope active_task_owns_branch to the polled project
active_task_owns_branch did an unscoped WHERE branch_name = ? — a cross-project branch_name collision (UUID-derived 8-char prefixes, theoretical) made the internal-PR reviewer skip the WRONG project's PR (project A's leftover PR skipped because project B happened to have an active task with the same branch). Pass project_id (in scope at the orchestrator call site) and add TaskTable.project_id == project_id to the WHERE. Correct for single-project tasks and MegaTask multi-repo batches alike: each root-subtask carries its own project_id matching its own repo, so a branch on project A's repo is owned only by a task whose project_id == A.
This commit is contained in:
@@ -146,17 +146,18 @@ def _branch_service(*, found: bool) -> TaskService:
|
||||
@pytest.mark.asyncio
|
||||
async def test_active_task_owns_branch_true_when_live_task_holds_it() -> None:
|
||||
assert (
|
||||
await _branch_service(found=True).active_task_owns_branch("feature/x") is True
|
||||
await _branch_service(found=True).active_task_owns_branch("feature/x", uuid4())
|
||||
is True
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_active_task_owns_branch_false_when_no_live_task() -> None:
|
||||
svc = _branch_service(found=False)
|
||||
assert await svc.active_task_owns_branch("feature/x") is False
|
||||
assert await svc.active_task_owns_branch("feature/x", uuid4()) is False
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_active_task_owns_branch_false_for_empty_branch() -> None:
|
||||
# No branch → cannot be owned; never hits the DB.
|
||||
assert await TaskService(MagicMock()).active_task_owns_branch("") is False
|
||||
assert await TaskService(MagicMock()).active_task_owns_branch("", uuid4()) is False
|
||||
|
||||
Reference in New Issue
Block a user