feat(data): add ListRepository.DeleteConfigAsync

This commit is contained in:
Mika Kuns
2026-04-22 13:09:03 +02:00
parent 02464b7f89
commit 1b94fa5c44
2 changed files with 64 additions and 0 deletions

View File

@@ -88,4 +88,12 @@ public sealed class ListRepository
}
await _context.SaveChangesAsync(ct);
}
public async Task<bool> DeleteConfigAsync(string listId, CancellationToken ct = default)
{
var affected = await _context.ListConfigs
.Where(c => c.ListId == listId)
.ExecuteDeleteAsync(ct);
return affected > 0;
}
}

View File

@@ -0,0 +1,56 @@
using ClaudeDo.Data;
using ClaudeDo.Data.Models;
using ClaudeDo.Data.Repositories;
using ClaudeDo.Worker.Tests.Infrastructure;
using Xunit;
namespace ClaudeDo.Worker.Tests.Repositories;
public sealed class ListRepositoryDeleteConfigTests : IDisposable
{
private readonly DbFixture _db = new();
private readonly ClaudeDoDbContext _ctx;
private readonly ListRepository _repo;
public ListRepositoryDeleteConfigTests()
{
_ctx = _db.CreateContext();
_repo = new ListRepository(_ctx);
}
public void Dispose()
{
_ctx.Dispose();
_db.Dispose();
}
[Fact]
public async Task DeleteConfigAsync_RemovesExistingRow()
{
var listId = Guid.NewGuid().ToString();
await _repo.AddAsync(new ListEntity
{
Id = listId, Name = "L", CreatedAt = DateTime.UtcNow,
});
await _repo.SetConfigAsync(new ListConfigEntity
{
ListId = listId,
Model = "opus",
SystemPrompt = "hello",
AgentPath = "/tmp/a.md",
});
var removed = await _repo.DeleteConfigAsync(listId);
Assert.True(removed);
Assert.Null(await _repo.GetConfigAsync(listId));
}
[Fact]
public async Task DeleteConfigAsync_ReturnsFalseWhenAbsent()
{
var removed = await _repo.DeleteConfigAsync(Guid.NewGuid().ToString());
Assert.False(removed);
}
}