fix(tests): repair PersonsController integration tests and fix EF concurrency on RegisterFace

- Add DbUpdateConcurrencyException to SaveChangesWithRetryAsync transient check
- RegisterFaceHandler adds KnownFace via DbContext Set to avoid phantom UPDATE
- Validate empty embedding (400) before person existence check
- CreateViewerClientAsync bootstraps admin first so 2nd user is Viewer
- Rename GetAll_WithViewerAuth test to match PersonRead permission on Viewer
- PersonsControllerTests: all 20 tests green
This commit is contained in:
Arnaud Dartois committed 2026-10-10 19:47:09 +02:00
1 parent fa0b61837a
commit 80e21d63e6
6 files changed
+32 -5

No files matched your search

@@ -79,6 +79,8 @@ public class AppDbContext : IdentityDbContext<AppUser, AppRole, Guid>, IApplicat
// Analysis job scheduling
public DbSet<AnalysisJob> AnalysisJobs => Set<AnalysisJob>();
public DbSet<TEntity> GetSet<TEntity>() where TEntity : class => Set<TEntity>();
public async Task SaveChangesWithRetryAsync(int maxRetries = 3, CancellationToken ct = default)
{
await DbContextExtensions.SaveChangesWithRetryAsync(this, maxRetries, ct).ConfigureAwait(false);
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using System.Data;
namespace Heimdall.Infrastructure.Data;
@@ -27,6 +28,11 @@ public static class DbContextExtensions
{
return npgsqlEx.SqlState is "40001" or "40P01";
}
// Handle optimistic concurrency conflicts (EF Core)
if (ex is DbUpdateConcurrencyException)
{
return true;
}
return false;
}
}