fix: do not recreate tasks that already have the derived UUID
Registrar-minted tasks keep the derived UUID with record_id unset. Inserting them again collides. Match by UUID, then write record_id. Assistant: grok Assistant-Session: 01a04996-76e8-7f53-b971-1885cfbed436
This commit is contained in:
parent
43e3edd727
commit
54b09ee9e2
2 changed files with 26 additions and 4 deletions
|
|
@ -1107,6 +1107,18 @@ class TestExistingWorkplanTasks:
|
|||
assert "DEMO-WP-0001-T09" in out.cancelled_tasks
|
||||
assert session.deleted == []
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_sets_record_id_when_the_derived_uuid_already_exists(self):
|
||||
row = _Row(slug="demo-wp-0001", status="active", path="workplans/a.md")
|
||||
existing = _TaskRow(None, status="done", title="Clear the stale hub rows", workplan_id=row.id)
|
||||
derived = self._derived(("DEMO-WP-0001-T01", "Clear the stale hub rows", "done"))
|
||||
existing.id = __import__("uuid").UUID(derived.workplans[0].tasks[0].uuid)
|
||||
session = _FakeSession(repo=_Repo(), rows=[row], task_rows=[existing])
|
||||
out = await fp.reset_repository_projection(session, "demo", derived=derived)
|
||||
assert out.created_tasks == []
|
||||
assert existing.record_id == "DEMO-WP-0001-T01"
|
||||
assert session.added == []
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_leaves_unidentified_tasks_alone(self):
|
||||
row = _Row(slug="demo-wp-0001", status="active", path="workplans/a.md")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue