fix(sitecallaudit): UpdatedAtUtc index + per-row pull resilience + UTC-convention + first-cycle test (review)

This commit is contained in:
Joseph Doherty
2026-06-15 10:47:25 -04:00
parent 963e3427da
commit 6b0140dd62
5 changed files with 118 additions and 21 deletions
@@ -121,6 +121,38 @@ public class SiteStreamPullSiteCallsTests : TestKit
Assert.Equal(since, capturedSince);
}
[Fact]
public async Task PullSiteCalls_SinceUtcUnset_PassesDateTimeMinValue()
{
// First reconciliation cycle: central has no cursor yet, so the request's
// SinceUtc wrapper is absent (null). The handler must default to
// DateTime.MinValue ("pull from the beginning of recorded history")
// without a null-deref — this proves the very first cycle doesn't crash.
var store = Substitute.For<IOperationTrackingStore>();
var captured = new DateTime(2099, 1, 1, 0, 0, 0, DateTimeKind.Utc); // sentinel
store.ReadChangedSinceAsync(Arg.Any<DateTime>(), Arg.Any<int>(), Arg.Any<CancellationToken>())
.Returns(call =>
{
captured = call.ArgAt<DateTime>(0);
return (IReadOnlyList<SiteCallOperational>)Array.Empty<SiteCallOperational>();
});
var server = CreateServer();
server.SetOperationTrackingStore(store);
// SinceUtc intentionally left unset (null) — the proto wrapper is absent.
var request = new PullSiteCallsRequest
{
BatchSize = 100,
};
var response = await server.PullSiteCalls(request, NewContext());
Assert.Empty(response.Operationals);
Assert.False(response.MoreAvailable);
Assert.Equal(DateTime.MinValue, captured);
}
[Fact]
public async Task PullSiteCalls_BatchSize3_Returns3Rows_MoreAvailableTrue()
{