test: remplace InMemory par Testcontainers PostgreSQL
- Ajoute Testcontainers.PostgreSql v4.13.0\n- PostgreSqlContainerFixture: collection fixture xUnit avec postgres:17-alpine\n- HeimdallWebApplicationFactory: accepte connectionString pour vrai PostgreSQL\n- PostgresTestBase: classe de base pour tous les tests integration\n- Ajoute [Collection("Postgres")] aux 9 classes de test\n- Database:MigrateOnStartup active quand PostgreSQL est utilise\n- Programme le Hangfire (skip en test via isTesting)\n\nAvant: InMemory (pas de contraintes, comportement different)\nApres: Vrai PostgreSQL dans un container temporaire\n\nTests: 226/226 passed (61 integration avec vrai PostgreSQL)
This commit is contained in:
1 parent
e309611f80
commit
ee7894646f
13 files changed
+145
-66
No files matched your search
@@ -4,16 +4,14 @@ using Shouldly;
|
||||
|
||||
namespace Heimdall.IntegrationTests.Controllers;
|
||||
|
||||
public class SitesControllerTests : IClassFixture<HeimdallWebApplicationFactory>
|
||||
public class SitesControllerTests : PostgresTestBase
|
||||
{
|
||||
private readonly HeimdallWebApplicationFactory _factory;
|
||||
|
||||
public SitesControllerTests(HeimdallWebApplicationFactory factory) => _factory = factory;
|
||||
public SitesControllerTests(PostgreSqlContainerFixture postgres) : base(postgres) { }
|
||||
|
||||
[Fact]
|
||||
public async Task GetSites_WithoutAuth_ReturnsUnauthorized()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
var client = Factory.CreateClient();
|
||||
var response = await client.GetAsync("api/sites?page=1&pageSize=10");
|
||||
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.Unauthorized);
|
||||
}
|
||||
@@ -21,7 +19,7 @@ public class SitesControllerTests : IClassFixture<HeimdallWebApplicationFactory>
|
||||
[Fact]
|
||||
public async Task CreateSite_WithAuth_ReturnsOk()
|
||||
{
|
||||
var client = await _factory.CreateAdminClientAsync();
|
||||
var client = await Factory.CreateAdminClientAsync();
|
||||
var response = await client.PostAsJsonAsync("api/sites", new
|
||||
{
|
||||
name = "Site Test",
|
||||
@@ -36,7 +34,7 @@ public class SitesControllerTests : IClassFixture<HeimdallWebApplicationFactory>
|
||||
[Fact]
|
||||
public async Task ListSites_WithAuth_ReturnsOk()
|
||||
{
|
||||
var client = await _factory.CreateAdminClientAsync();
|
||||
var client = await Factory.CreateAdminClientAsync();
|
||||
var response = await client.GetAsync("api/sites?page=1&pageSize=10");
|
||||
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user