fix(mcp): stop set_list_config from clearing settings it doesn't expose
This commit is contained in:
@@ -223,6 +223,72 @@ public sealed class ConfigMcpToolsTests : IDisposable
|
||||
_sut.SetTaskConfig(task.Id, clearFields: new[] { "bogus" }, cancellationToken: CancellationToken.None));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SetListConfig_PreservesSettingsItDoesNotExpose()
|
||||
{
|
||||
var listId = await SeedListAsync();
|
||||
await _lists.SetConfigAsync(new ListConfigEntity
|
||||
{
|
||||
ListId = listId,
|
||||
Model = "sonnet",
|
||||
SessionSkills = "[\"superpowers\"]",
|
||||
VerifyCommand = "dotnet build",
|
||||
SerializeOnFileOverlap = true,
|
||||
});
|
||||
|
||||
await _sut.SetListConfig(listId, model: "opus", cancellationToken: CancellationToken.None);
|
||||
|
||||
var cfg = await _lists.GetConfigAsync(listId);
|
||||
Assert.NotNull(cfg);
|
||||
Assert.Equal("opus", cfg!.Model);
|
||||
Assert.Equal("[\"superpowers\"]", cfg.SessionSkills);
|
||||
Assert.Equal("dotnet build", cfg.VerifyCommand);
|
||||
// SetConfigAsync copies the entity verbatim, so a field this tool doesn't expose would
|
||||
// reset to its default unless it is carried over explicitly.
|
||||
Assert.True(cfg.SerializeOnFileOverlap);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SetListConfig_ClearingEveryExposedField_KeepsRowWhenOtherSettingsRemain()
|
||||
{
|
||||
var listId = await SeedListAsync();
|
||||
await _lists.SetConfigAsync(new ListConfigEntity
|
||||
{
|
||||
ListId = listId,
|
||||
Model = "sonnet",
|
||||
VerifyCommand = "dotnet build",
|
||||
SerializeOnFileOverlap = true,
|
||||
});
|
||||
|
||||
var result = await _sut.SetListConfig(
|
||||
listId,
|
||||
clearFields: new[] { "model", "systemPrompt", "agentPath", "maxTurns" },
|
||||
cancellationToken: CancellationToken.None);
|
||||
|
||||
Assert.True(result.Ok);
|
||||
Assert.Null(result.Config);
|
||||
|
||||
var cfg = await _lists.GetConfigAsync(listId);
|
||||
Assert.NotNull(cfg);
|
||||
Assert.Null(cfg!.Model);
|
||||
Assert.Equal("dotnet build", cfg.VerifyCommand);
|
||||
Assert.True(cfg.SerializeOnFileOverlap);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task SetListConfig_ClearingEveryField_DeletesRowWhenNothingElseIsSet()
|
||||
{
|
||||
var listId = await SeedListAsync();
|
||||
await _sut.SetListConfig(listId, "sonnet", cancellationToken: CancellationToken.None);
|
||||
|
||||
await _sut.SetListConfig(
|
||||
listId,
|
||||
clearFields: new[] { "model", "systemPrompt", "agentPath", "maxTurns" },
|
||||
cancellationToken: CancellationToken.None);
|
||||
|
||||
Assert.Null(await _lists.GetConfigAsync(listId));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetTaskConfig_NoOverrideSet_ReturnsNotFound()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user