From f704244b84f2c9319042c28b5a5ff9e7e2bc0083 Mon Sep 17 00:00:00 2001 From: mika kuns Date: Thu, 23 Apr 2026 18:15:12 +0200 Subject: [PATCH] test(data): parent delete with children is restricted --- .../TaskRepositoryPlanningTests.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/ClaudeDo.Worker.Tests/Repositories/TaskRepositoryPlanningTests.cs b/tests/ClaudeDo.Worker.Tests/Repositories/TaskRepositoryPlanningTests.cs index c95fe8e..94a4e9c 100644 --- a/tests/ClaudeDo.Worker.Tests/Repositories/TaskRepositoryPlanningTests.cs +++ b/tests/ClaudeDo.Worker.Tests/Repositories/TaskRepositoryPlanningTests.cs @@ -283,6 +283,25 @@ public sealed class TaskRepositoryPlanningTests : IDisposable Assert.False(ok); } + [Fact] + public async Task DeleteAsync_ParentWithChildren_ThrowsOrDoesNotDelete() + { + var listId = await CreateListAsync(); + var parent = MakeTask(listId, TaskStatus.Planning); + await _tasks.AddAsync(parent); + await _tasks.CreateChildAsync(parent.Id, "c", null, null, null); + + // ExecuteDelete bypasses EF change tracking, so SQLite's FK enforcement + // (foreign_keys = ON, set by ClaudeDoDbContext) throws SqliteException directly. + await Assert.ThrowsAsync(async () => + { + await _tasks.DeleteAsync(parent.Id); + }); + + var stillThere = await _tasks.GetByIdAsync(parent.Id); + Assert.NotNull(stillThere); + } + [Fact] public async Task GetNextQueuedAgentTask_SkipsDraftPlanningPlanned() {