fix(worker): reuse shared hub fake and guard blank list name

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-05-30 13:51:34 +02:00
parent 53f4e2de0f
commit ac2f1d824e
2 changed files with 3 additions and 26 deletions

View File

@@ -47,6 +47,8 @@ public sealed class ListMcpTools
var entity = await _lists.GetByIdAsync(listId, cancellationToken) var entity = await _lists.GetByIdAsync(listId, cancellationToken)
?? throw new InvalidOperationException($"List {listId} not found."); ?? throw new InvalidOperationException($"List {listId} not found.");
if (name is not null && string.IsNullOrWhiteSpace(name))
throw new InvalidOperationException("name cannot be blank.");
if (name is not null) entity.Name = name; if (name is not null) entity.Name = name;
if (workingDir is not null) if (workingDir is not null)
entity.WorkingDir = string.IsNullOrWhiteSpace(workingDir) ? null : workingDir; entity.WorkingDir = string.IsNullOrWhiteSpace(workingDir) ? null : workingDir;

View File

@@ -4,34 +4,9 @@ using ClaudeDo.Data.Repositories;
using ClaudeDo.Worker.External; using ClaudeDo.Worker.External;
using ClaudeDo.Worker.Hub; using ClaudeDo.Worker.Hub;
using ClaudeDo.Worker.Tests.Infrastructure; using ClaudeDo.Worker.Tests.Infrastructure;
using Microsoft.AspNetCore.SignalR;
namespace ClaudeDo.Worker.Tests.External; namespace ClaudeDo.Worker.Tests.External;
internal sealed class ListToolsHubClients : IHubClients
{
public ListToolsClientProxy Proxy { get; } = new();
public IClientProxy All => Proxy;
public IClientProxy AllExcept(IReadOnlyList<string> e) => Proxy;
public IClientProxy Client(string c) => Proxy;
public IClientProxy Clients(IReadOnlyList<string> c) => Proxy;
public IClientProxy Group(string g) => Proxy;
public IClientProxy GroupExcept(string g, IReadOnlyList<string> e) => Proxy;
public IClientProxy Groups(IReadOnlyList<string> g) => Proxy;
public IClientProxy User(string u) => Proxy;
public IClientProxy Users(IReadOnlyList<string> u) => Proxy;
}
internal sealed class ListToolsClientProxy : IClientProxy
{
public Task SendCoreAsync(string m, object?[] a, CancellationToken ct = default) => Task.CompletedTask;
}
internal sealed class ListToolsHubContext : IHubContext<WorkerHub>
{
public ListToolsHubClients RecordingClients { get; } = new();
public IHubClients Clients => RecordingClients;
public IGroupManager Groups => throw new NotImplementedException();
}
public sealed class ListMcpToolsTests : IDisposable public sealed class ListMcpToolsTests : IDisposable
{ {
private readonly DbFixture _db = new(); private readonly DbFixture _db = new();
@@ -43,7 +18,7 @@ public sealed class ListMcpToolsTests : IDisposable
{ {
_ctx = _db.CreateContext(); _ctx = _db.CreateContext();
_lists = new ListRepository(_ctx); _lists = new ListRepository(_ctx);
_sut = new ListMcpTools(_lists, new HubBroadcaster(new ListToolsHubContext())); _sut = new ListMcpTools(_lists, new HubBroadcaster(new CapturingHubContext()));
} }
public void Dispose() { _ctx.Dispose(); _db.Dispose(); } public void Dispose() { _ctx.Dispose(); _db.Dispose(); }