up
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Text.Json.Nodes;
|
||||
using FluentAssertions;
|
||||
using StellaOps.Findings.Ledger.Domain;
|
||||
using StellaOps.Findings.Ledger.Observability;
|
||||
using StellaOps.Findings.Ledger.Services.Incident;
|
||||
using Xunit;
|
||||
|
||||
namespace StellaOps.Findings.Ledger.Tests.Observability;
|
||||
@@ -45,6 +46,49 @@ public class LedgerTimelineTests
|
||||
state["Status"].Should().Be("affected");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmitIncidentModeChanged_writes_structured_log()
|
||||
{
|
||||
var logger = new TestLogger<LedgerTimelineTests>();
|
||||
var snapshot = new LedgerIncidentSnapshot(
|
||||
IsActive: true,
|
||||
ActivationId: "act-123",
|
||||
Actor: "actor-1",
|
||||
Reason: "reason",
|
||||
TenantId: "tenant-a",
|
||||
ChangedAt: DateTimeOffset.UtcNow,
|
||||
ExpiresAt: DateTimeOffset.UtcNow.AddMinutes(10),
|
||||
RetentionExtensionDays: 30);
|
||||
|
||||
LedgerTimeline.EmitIncidentModeChanged(logger, snapshot, wasReactivation: false);
|
||||
|
||||
var entry = logger.Entries.Single(e => e.EventId.Id == 6901);
|
||||
var state = AsDictionary(entry.State);
|
||||
state["RetentionExtensionDays"].Should().Be(30);
|
||||
state["ActivationId"].Should().Be("act-123");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmitIncidentLagTrace_writes_structured_log()
|
||||
{
|
||||
var logger = new TestLogger<LedgerTimelineTests>();
|
||||
var sample = new ProjectionLagSample(
|
||||
"tenant-a",
|
||||
Guid.NewGuid(),
|
||||
10,
|
||||
"finding.created",
|
||||
"v1",
|
||||
12.5,
|
||||
DateTimeOffset.UtcNow.AddSeconds(-12),
|
||||
DateTimeOffset.UtcNow);
|
||||
|
||||
LedgerTimeline.EmitIncidentLagTrace(logger, sample);
|
||||
|
||||
var entry = logger.Entries.Single(e => e.EventId.Id == 6902);
|
||||
var state = AsDictionary(entry.State);
|
||||
state["LagSeconds"].Should().Be(12.5);
|
||||
}
|
||||
|
||||
private static LedgerEventRecord CreateRecord()
|
||||
{
|
||||
var payload = new JsonObject { ["status"] = "affected" };
|
||||
|
||||
Reference in New Issue
Block a user