test(worker): add integration test for auto-retry flow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -213,6 +213,48 @@ public sealed class QueueServiceTests : IDisposable
|
||||
Assert.True(cancelled);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RunNow_AutoRetries_On_Failure_With_SessionId()
|
||||
{
|
||||
var (listId, agentTagId) = await SeedListWithAgentTag();
|
||||
var task = await SeedQueuedTask(listId);
|
||||
|
||||
var callCount = 0;
|
||||
var (service, fake) = CreateService((prompt, dir, args, onLine, ct) =>
|
||||
{
|
||||
callCount++;
|
||||
if (callCount == 1)
|
||||
{
|
||||
return Task.FromResult(new RunResult
|
||||
{
|
||||
ExitCode = 1,
|
||||
ErrorMarkdown = "something broke",
|
||||
SessionId = "sess-retry-test",
|
||||
});
|
||||
}
|
||||
return Task.FromResult(new RunResult
|
||||
{
|
||||
ExitCode = 0,
|
||||
ResultMarkdown = "fixed it",
|
||||
SessionId = "sess-retry-test",
|
||||
});
|
||||
});
|
||||
|
||||
await service.StartAsync(CancellationToken.None);
|
||||
await service.RunNow(task.Id);
|
||||
|
||||
// Wait for both runs to complete.
|
||||
await Task.Delay(2000);
|
||||
|
||||
await service.StopAsync(CancellationToken.None);
|
||||
|
||||
Assert.Equal(2, callCount);
|
||||
|
||||
var finalTask = await _taskRepo.GetByIdAsync(task.Id);
|
||||
Assert.NotNull(finalTask);
|
||||
Assert.Equal(TaskStatus.Done, finalTask.Status);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetActive_Returns_Running_Slots()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user