fix(tests): InMemory DB isolation + refactor test helpers
- Fix: InMemory database name now unique per test factory instance (was using process-wide env var, now per-host config via UseSetting) - Refactor: all integration tests use shared TestHelpers.CreateAdminClientAsync - New: register-admin endpoint (test/dev only) creates Admin users directly - New: TestHelpers.cs with extension method for admin client creation - Cleanup: removed bootstrap template files, old Counter/Weather pages - Cleanup: simplified app.css with MudBlazor-only styles - Seed: demo admin + demo site created in Development mode
This commit is contained in:
1 parent
129bcfa9d7
commit
da123ec544
60 files changed
+148
-59912
No files matched your search
@@ -20,17 +20,21 @@ public static class DependencyInjection
|
||||
var env = environmentName ?? Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production";
|
||||
var isTesting = env == "Testing";
|
||||
|
||||
if (!isTesting)
|
||||
{
|
||||
var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL")
|
||||
?? configuration.GetConnectionString("Default")
|
||||
?? "Host=localhost;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall";
|
||||
var connectionString = Environment.GetEnvironmentVariable("DATABASE_URL")
|
||||
?? configuration.GetConnectionString("Default")
|
||||
?? "Host=localhost;Port=5432;Database=heimdall;Username=heimdall;Password=heimdall";
|
||||
|
||||
if (isTesting)
|
||||
{
|
||||
var dbName = configuration.GetValue<string>("InMemoryDbName") ?? "HeimdallTestDb";
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
options.UseInMemoryDatabase(dbName));
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddDbContext<AppDbContext>(options =>
|
||||
{
|
||||
options.UseNpgsql(connectionString, npgsql =>
|
||||
npgsql.MigrationsHistoryTable("__EFMigrationsHistory", "public"));
|
||||
});
|
||||
npgsql.MigrationsHistoryTable("__EFMigrationsHistory", "public")));
|
||||
}
|
||||
|
||||
// Identity
|
||||
|
||||
Reference in new issue
Block a user