Files
Heimdall/tests/Heimdall.Infrastructure.Tests/PostgreSqlContainerFixture.cs
T
Arnaud Dartois 58a3ce5b1b 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)
2026-07-21 12:19:43 +00:00

35 lines
953 B
C#

using Testcontainers.PostgreSql;
namespace Heimdall.Infrastructure.Tests;
/// <summary>
/// xUnit collection fixture that manages a PostgreSQL Testcontainer.
/// One container per test collection — shared across all test classes.
/// </summary>
public class PostgreSqlContainerFixture : IAsyncLifetime
{
private readonly PostgreSqlContainer _container = new PostgreSqlBuilder("postgres:17-alpine")
.WithDatabase("heimdall_test")
.WithUsername("heimdall")
.WithPassword("heimdall_test_pwd")
.WithCleanUp(true)
.Build();
public string ConnectionString => _container.GetConnectionString();
public async Task InitializeAsync()
{
await _container.StartAsync();
}
public async Task DisposeAsync()
{
await _container.DisposeAsync();
}
}
[CollectionDefinition("PostgresInfra")]
public class PostgresInfraFixture : ICollectionFixture<PostgreSqlContainerFixture>
{
}