fix(site-call-audit): an unknown-status row no longer aborts the rest of a batched page (review 2026-10-21 06/PERF-2 follow-up)

This commit is contained in:
Joseph Doherty
2026-10-22 09:49:54 -04:00
parent 5f7f889a96
commit 46ab5594ec
2 changed files with 60 additions and 5 deletions
@@ -1018,6 +1018,40 @@ public class SiteCallAuditRepositoryTests : IClassFixture<MsSqlMigrationFixture>
Assert.Equal("Submitted", stored.Status);
}
/// <summary>
/// Verifies that a row with an unknown status does not stop the rest of the page: every
/// valid row is applied and the unknown-status failure is rethrown at the end (adversarial
/// review of 06/PERF-2).
/// </summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[SkippableFact]
public async Task UpsertManyAsync_UnknownStatus_StillAppliesTheRestOfThePage()
{
Skip.IfNot(_fixture.Available, _fixture.SkipReason);
var site = NewSiteId();
var good1 = TrackedOperationId.New();
var bad = TrackedOperationId.New();
var good2 = TrackedOperationId.New();
var page = new List<SiteCall>
{
NewRow(good1, site, status: "Submitted"),
NewRow(bad, site, status: "NotAStatus"),
NewRow(good2, site, status: "Submitted"),
};
await using (var context = CreateContext())
{
await Assert.ThrowsAsync<ArgumentException>(
() => new SiteCallAuditRepository(context).UpsertManyAsync(page));
}
await using var read = CreateContext();
var repo = new SiteCallAuditRepository(read);
Assert.NotNull(await repo.GetAsync(good1));
Assert.NotNull(await repo.GetAsync(good2));
Assert.Null(await repo.GetAsync(bad));
}
private ScadaBridgeDbContext CreateContext(DbCommandInterceptor interceptor)
{
var options = new DbContextOptionsBuilder<ScadaBridgeDbContext>()