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
@@ -5,16 +5,14 @@ using Shouldly;
|
||||
|
||||
namespace Heimdall.IntegrationTests.Controllers;
|
||||
|
||||
public class UsersControllerTests : IClassFixture<HeimdallWebApplicationFactory>
|
||||
public class UsersControllerTests : PostgresTestBase
|
||||
{
|
||||
private readonly HeimdallWebApplicationFactory _factory;
|
||||
|
||||
public UsersControllerTests(HeimdallWebApplicationFactory factory) => _factory = factory;
|
||||
public UsersControllerTests(PostgreSqlContainerFixture postgres) : base(postgres) { }
|
||||
|
||||
[Fact]
|
||||
public async Task ListUsers_WithAdminAuth_ReturnsOk()
|
||||
{
|
||||
var client = await _factory.CreateAdminClientAsync();
|
||||
var client = await Factory.CreateAdminClientAsync();
|
||||
var response = await client.GetAsync("api/users?page=1&pageSize=20");
|
||||
response.StatusCode.ShouldBe(System.Net.HttpStatusCode.OK);
|
||||
}
|
||||
@@ -22,7 +20,7 @@ public class UsersControllerTests : IClassFixture<HeimdallWebApplicationFactory>
|
||||
[Fact]
|
||||
public async Task CreateUser_WithAdminAuth_ReturnsOk()
|
||||
{
|
||||
var client = await _factory.CreateAdminClientAsync();
|
||||
var client = await Factory.CreateAdminClientAsync();
|
||||
var response = await client.PostAsJsonAsync("api/users", new
|
||||
{
|
||||
email = $"newuser-{Guid.NewGuid()}@heimdall.test",
|
||||
@@ -36,7 +34,7 @@ public class UsersControllerTests : IClassFixture<HeimdallWebApplicationFactory>
|
||||
[Fact]
|
||||
public async Task LockUser_WithAdminAuth_ReturnsOk()
|
||||
{
|
||||
var client = await _factory.CreateAdminClientAsync();
|
||||
var client = await Factory.CreateAdminClientAsync();
|
||||
var createResponse = await client.PostAsJsonAsync("api/users", new
|
||||
{
|
||||
email = $"lockuser-{Guid.NewGuid()}@heimdall.test",
|
||||
@@ -54,7 +52,7 @@ public class UsersControllerTests : IClassFixture<HeimdallWebApplicationFactory>
|
||||
[Fact]
|
||||
public async Task ResetPassword_WithAdminAuth_ReturnsTemporaryPassword()
|
||||
{
|
||||
var client = await _factory.CreateAdminClientAsync();
|
||||
var client = await Factory.CreateAdminClientAsync();
|
||||
var createResponse = await client.PostAsJsonAsync("api/users", new
|
||||
{
|
||||
email = $"resetpwd-{Guid.NewGuid()}@heimdall.test",
|
||||
|
||||
Reference in new issue
Block a user