feat(esg): --timeout-seconds on external-system create/update (management command + CLI, additive contract)
Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
This commit is contained in:
@@ -2923,4 +2923,56 @@ public class ManagementActorTests : TestKit, IDisposable
|
||||
Assert.Contains("MissingSharedSchema", msg.JsonData, StringComparison.Ordinal);
|
||||
Assert.Contains("\"category\":15", msg.JsonData, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// PLAN-06 Task 11: per-system ESG TimeoutSeconds management commands
|
||||
// ========================================================================
|
||||
|
||||
[Fact]
|
||||
public void CreateExternalSystem_PersistsTimeoutSeconds()
|
||||
{
|
||||
var extRepo = Substitute.For<IExternalSystemRepository>();
|
||||
_services.AddScoped(_ => extRepo);
|
||||
|
||||
var actor = CreateActor();
|
||||
var envelope = Envelope(
|
||||
new CreateExternalSystemCommand("Sys", "http://x", "none", null, TimeoutSeconds: 15),
|
||||
"Designer");
|
||||
|
||||
actor.Tell(envelope);
|
||||
|
||||
var response = ExpectMsg<ManagementSuccess>(TimeSpan.FromSeconds(5));
|
||||
Assert.Equal(envelope.CorrelationId, response.CorrelationId);
|
||||
extRepo.Received(1).AddExternalSystemAsync(
|
||||
Arg.Is<Commons.Entities.ExternalSystems.ExternalSystemDefinition>(d => d.TimeoutSeconds == 15),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void UpdateExternalSystem_NullTimeout_PreservesExisting()
|
||||
{
|
||||
var existing = new Commons.Entities.ExternalSystems.ExternalSystemDefinition("Sys", "http://x", "none")
|
||||
{
|
||||
Id = 7,
|
||||
TimeoutSeconds = 42
|
||||
};
|
||||
var extRepo = Substitute.For<IExternalSystemRepository>();
|
||||
extRepo.GetExternalSystemByIdAsync(7, Arg.Any<CancellationToken>()).Returns(existing);
|
||||
_services.AddScoped(_ => extRepo);
|
||||
|
||||
var actor = CreateActor();
|
||||
// TimeoutSeconds omitted (null) => existing 42 must be preserved.
|
||||
var envelope = Envelope(
|
||||
new UpdateExternalSystemCommand(7, "Sys", "http://x", "none", null),
|
||||
"Designer");
|
||||
|
||||
actor.Tell(envelope);
|
||||
|
||||
var response = ExpectMsg<ManagementSuccess>(TimeSpan.FromSeconds(5));
|
||||
Assert.Equal(envelope.CorrelationId, response.CorrelationId);
|
||||
Assert.Equal(42, existing.TimeoutSeconds);
|
||||
extRepo.Received(1).UpdateExternalSystemAsync(
|
||||
Arg.Is<Commons.Entities.ExternalSystems.ExternalSystemDefinition>(d => d.TimeoutSeconds == 42),
|
||||
Arg.Any<CancellationToken>());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user