test(data): parent delete with children is restricted

This commit is contained in:
mika kuns
2026-04-23 18:15:12 +02:00
parent 782110604b
commit f704244b84

View File

@@ -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<Microsoft.Data.Sqlite.SqliteException>(async () =>
{
await _tasks.DeleteAsync(parent.Id);
});
var stillThere = await _tasks.GetByIdAsync(parent.Id);
Assert.NotNull(stillThere);
}
[Fact]
public async Task GetNextQueuedAgentTask_SkipsDraftPlanningPlanned()
{