- CancelAsync now signals the running Claude process of the cancelled task and its cascaded children via the new RunCancellationRegistry (queue + override slots register their CTS there) instead of only flipping DB state. - external MCP review_task 'approve' now mirrors the hub's ApproveReview: unit merge for parents, ApproveAndMergeAsync for childless tasks, optional targetBranch; ReviewTaskResult carries mergeStatus/conflicts.
52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using ClaudeDo.Worker.Queue;
|
|
|
|
namespace ClaudeDo.Worker.Tests.Queue;
|
|
|
|
public sealed class RunCancellationRegistryTests
|
|
{
|
|
[Fact]
|
|
public void TryCancel_RegisteredTask_CancelsAndReturnsTrue()
|
|
{
|
|
var sut = new RunCancellationRegistry();
|
|
using var cts = new CancellationTokenSource();
|
|
sut.Register("t1", cts);
|
|
|
|
Assert.True(sut.TryCancel("t1"));
|
|
Assert.True(cts.IsCancellationRequested);
|
|
}
|
|
|
|
[Fact]
|
|
public void TryCancel_UnknownTask_ReturnsFalse()
|
|
{
|
|
var sut = new RunCancellationRegistry();
|
|
Assert.False(sut.TryCancel("nope"));
|
|
}
|
|
|
|
[Fact]
|
|
public void Unregister_RemovesOnlyTheGivenRegistration()
|
|
{
|
|
var sut = new RunCancellationRegistry();
|
|
using var stale = new CancellationTokenSource();
|
|
using var current = new CancellationTokenSource();
|
|
|
|
sut.Register("t1", stale);
|
|
sut.Register("t1", current); // re-run replaced the registration
|
|
sut.Unregister("t1", stale); // late cleanup of the old slot must not evict the new one
|
|
|
|
Assert.True(sut.TryCancel("t1"));
|
|
Assert.True(current.IsCancellationRequested);
|
|
Assert.False(stale.IsCancellationRequested);
|
|
}
|
|
|
|
[Fact]
|
|
public void TryCancel_DisposedCts_ReturnsFalse()
|
|
{
|
|
var sut = new RunCancellationRegistry();
|
|
var cts = new CancellationTokenSource();
|
|
sut.Register("t1", cts);
|
|
cts.Dispose();
|
|
|
|
Assert.False(sut.TryCancel("t1"));
|
|
}
|
|
}
|