chore: vire toute trace d'InMemory, remplace par Testcontainers PostgreSQL
- Supprime InMemory de tous les .csproj (Infrastructure, Domain.Tests, IntegrationTests)\n- Supprime le branchement Database:Provider=InMemory de DependencyInjection.cs\n (plus que du PostgreSQL natif)\n- Infrastructure.Tests: CameraAssignment + CameraEvent tests -> Testcontainers\n- PostgreSqlContainerFixture ajoute aux Infrastructure.Tests\n- appsettings.Testing.json: retire Database:Provider et Hangfire:Enabled\n- 4 tests echouent encore: bugs pre-existants masques par InMemory\n (FK non respectees, donnees de test erronees)\n\nTests: 222/226 passed (4 pre-existants lies aux FK)
This commit is contained in:
1 parent
ee7894646f
commit
58a3ce5b1b
12 files changed
+77
-55
No files matched your search
@@ -22,32 +22,19 @@ public static class DependencyInjection
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
var dbProvider = configuration.GetValue<string>("Database:Provider") ?? "PostgreSQL";
|
||||
|
||||
// EF Core interceptor (registered as singleton — it is stateless)
|
||||
services.AddSingleton<AuditInterceptor>();
|
||||
|
||||
if (dbProvider == "InMemory")
|
||||
{
|
||||
var dbName = configuration.GetValue<string>("InMemoryDbName") ?? "HeimdallTestDb";
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseInMemoryDatabase(dbName));
|
||||
services.AddDbContextFactory<AppDbContext>(options =>
|
||||
options.UseInMemoryDatabase(dbName));
|
||||
}
|
||||
else
|
||||
{
|
||||
var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL")
|
||||
?? configuration.GetConnectionString("Default")
|
||||
?? throw new InvalidOperationException(
|
||||
"Database connection string is not configured. Set DATABASE_URL env var or ConnectionStrings:Default.");
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseNpgsql(connectionString, npgsql =>
|
||||
npgsql.MigrationsHistoryTable("__EFMigrationsHistory", "public")));
|
||||
services.AddDbContextFactory<AppDbContext>(options =>
|
||||
options.UseNpgsql(connectionString, npgsql =>
|
||||
npgsql.MigrationsHistoryTable("__EFMigrationsHistory", "public")));
|
||||
}
|
||||
var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL")
|
||||
?? configuration.GetConnectionString("Default")
|
||||
?? throw new InvalidOperationException(
|
||||
"Database connection string is not configured. Set DATABASE_URL env var or ConnectionStrings:Default.");
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseNpgsql(connectionString, npgsql =>
|
||||
npgsql.MigrationsHistoryTable("__EFMigrationsHistory", "public")));
|
||||
services.AddDbContextFactory<AppDbContext>(options =>
|
||||
options.UseNpgsql(connectionString, npgsql =>
|
||||
npgsql.MigrationsHistoryTable("__EFMigrationsHistory", "public")));
|
||||
|
||||
// Identity
|
||||
services.AddIdentity<AppUser, AppRole>(options =>
|
||||
|
||||
Reference in new issue
Block a user