Add remain services and fixes
This commit is contained in:
@@ -32,17 +32,20 @@ public class ApiFixture : WebApplicationFactory<Program>, IAsyncLifetime
|
||||
|
||||
public async Task InitializeAsync()
|
||||
{
|
||||
// Apply migrations before the host starts — background services such as
|
||||
// ThresholdCacheLoader query the database during StartAsync.
|
||||
// Apply migrations and clean stale data before the host starts — background
|
||||
// services such as ThresholdCacheLoader query the database during StartAsync,
|
||||
// so the reset must happen while no hosted service holds a lock.
|
||||
var connectionString = "Host=localhost;Port=5436;Database=vigilcare_test;Username=postgres;Password=password";
|
||||
var options = new DbContextOptionsBuilder<AppDbContext>()
|
||||
.UseNpgsql(connectionString)
|
||||
.Options;
|
||||
await using (var migrateDb = new AppDbContext(options))
|
||||
{
|
||||
await migrateDb.Database.MigrateAsync();
|
||||
await DbResetHelper.ResetAsync(migrateDb);
|
||||
}
|
||||
|
||||
using var scope = Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<AppDbContext>();
|
||||
var redis = scope.ServiceProvider.GetRequiredService<IConnectionMultiplexer>();
|
||||
var server = redis.GetServer(redis.GetEndPoints().First());
|
||||
await server.FlushDatabaseAsync(1);
|
||||
|
||||
Reference in New Issue
Block a user