fix(notification-outbox): fall back to Target for empty notification list name
This commit is contained in:
@@ -67,6 +67,39 @@ public class NotificationForwarderTests : TestKit
|
||||
Assert.True(await deliverTask);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Deliver_FallsBackToTarget_WhenPayloadListNameIsEmpty()
|
||||
{
|
||||
var centralProbe = CreateTestProbe();
|
||||
var forwarder = new NotificationForwarder(
|
||||
centralProbe.Ref, "site-7", ForwardTimeout);
|
||||
|
||||
// A buffered payload carrying an empty-string ListName: the empty value must not
|
||||
// be forwarded — the forwarder falls back to the S&F message Target instead.
|
||||
var payload = JsonSerializer.Serialize(new
|
||||
{
|
||||
ListName = "",
|
||||
Subject = "Pump alarm",
|
||||
Message = "Pump 3 tripped"
|
||||
});
|
||||
var msg = new StoreAndForwardMessage
|
||||
{
|
||||
Id = "msg-empty-list",
|
||||
Category = StoreAndForwardCategory.Notification,
|
||||
Target = "Operators",
|
||||
PayloadJson = payload,
|
||||
OriginInstanceName = "Plant.Pump3",
|
||||
};
|
||||
|
||||
var deliverTask = forwarder.DeliverAsync(msg);
|
||||
|
||||
var submit = centralProbe.ExpectMsg<NotificationSubmit>();
|
||||
Assert.Equal("Operators", submit.ListName);
|
||||
centralProbe.Reply(new NotificationSubmitAck(submit.NotificationId, Accepted: true, Error: null));
|
||||
|
||||
Assert.True(await deliverTask);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Deliver_ThrowsTransient_WhenAckIsNotAccepted()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user