feat(auditlog): NotifyDeliver rows carry the originating ExecutionId
This commit is contained in:
@@ -268,6 +268,7 @@ public class NotificationOutboxConfigurationTests : IDisposable
|
||||
var lastAttemptAt = new DateTimeOffset(2026, 5, 19, 8, 1, 0, TimeSpan.Zero);
|
||||
var nextAttemptAt = new DateTimeOffset(2026, 5, 19, 8, 2, 0, TimeSpan.Zero);
|
||||
var deliveredAt = new DateTimeOffset(2026, 5, 19, 8, 3, 0, TimeSpan.Zero);
|
||||
var originExecutionId = Guid.NewGuid();
|
||||
|
||||
var notification = new Notification(id, NotificationType.Email, "Ops List",
|
||||
"High Tank Level", "Tank 4 exceeded the high level threshold.", "site-north")
|
||||
@@ -279,6 +280,7 @@ public class NotificationOutboxConfigurationTests : IDisposable
|
||||
ResolvedTargets = "ops@example.test;duty@example.test",
|
||||
SourceInstanceId = "instance-42",
|
||||
SourceScript = "TankLevelAlarm",
|
||||
OriginExecutionId = originExecutionId,
|
||||
SiteEnqueuedAt = siteEnqueuedAt,
|
||||
CreatedAt = createdAt,
|
||||
LastAttemptAt = lastAttemptAt,
|
||||
@@ -311,6 +313,27 @@ public class NotificationOutboxConfigurationTests : IDisposable
|
||||
Assert.Equal(lastAttemptAt, loaded.LastAttemptAt);
|
||||
Assert.Equal(nextAttemptAt, loaded.NextAttemptAt);
|
||||
Assert.Equal(deliveredAt, loaded.DeliveredAt);
|
||||
Assert.Equal(originExecutionId, loaded.OriginExecutionId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Notification_NullOriginExecutionId_RoundTripsAsNull()
|
||||
{
|
||||
// Audit Log #23: OriginExecutionId is an additive nullable column —
|
||||
// notifications raised outside a script execution (or submitted before
|
||||
// the column existed) persist and reload it as null.
|
||||
var id = Guid.NewGuid().ToString();
|
||||
var notification = new Notification(id, NotificationType.Email, "Ops List",
|
||||
"Subject", "Body", "site-north");
|
||||
|
||||
_context.Notifications.Add(notification);
|
||||
await _context.SaveChangesAsync();
|
||||
_context.ChangeTracker.Clear();
|
||||
|
||||
var loaded = await _context.Notifications.FindAsync(id);
|
||||
|
||||
Assert.NotNull(loaded);
|
||||
Assert.Null(loaded!.OriginExecutionId);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user