feat(data): TaskRepository.CreateChildAsync
This commit is contained in:
@@ -80,4 +80,43 @@ public sealed class TaskRepositoryPlanningTests : IDisposable
|
||||
Assert.Equal("b", children[0].Title);
|
||||
Assert.Equal("a", children[1].Title);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateChildAsync_CreatesDraftUnderParent()
|
||||
{
|
||||
var listId = await CreateListAsync();
|
||||
var parent = MakeTask(listId, TaskStatus.Planning);
|
||||
await _tasks.AddAsync(parent);
|
||||
|
||||
var child = await _tasks.CreateChildAsync(
|
||||
parent.Id,
|
||||
title: "child title",
|
||||
description: "child desc",
|
||||
tagNames: new[] { "agent" },
|
||||
commitType: "feat");
|
||||
|
||||
Assert.Equal(TaskStatus.Draft, child.Status);
|
||||
Assert.Equal(parent.Id, child.ParentTaskId);
|
||||
Assert.Equal(listId, child.ListId);
|
||||
Assert.Equal("child title", child.Title);
|
||||
Assert.Equal("child desc", child.Description);
|
||||
Assert.Equal("feat", child.CommitType);
|
||||
|
||||
var loaded = await _tasks.GetByIdAsync(child.Id);
|
||||
Assert.NotNull(loaded);
|
||||
Assert.Equal(TaskStatus.Draft, loaded!.Status);
|
||||
|
||||
var tags = await _tasks.GetTagsAsync(child.Id);
|
||||
Assert.Contains(tags, t => t.Name == "agent");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task CreateChildAsync_ThrowsIfParentNotFound()
|
||||
{
|
||||
var listId = await CreateListAsync();
|
||||
_ = listId; // just to create the DB
|
||||
|
||||
await Assert.ThrowsAsync<InvalidOperationException>(() =>
|
||||
_tasks.CreateChildAsync("nonexistent-parent-id", "t", null, null, null));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user