26 lines
969 B
C#
26 lines
969 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Tiku.IntegrationTests.Api;
|
|
using Tiku.Infrastructure.Persistence;
|
|
|
|
namespace Tiku.IntegrationTests;
|
|
|
|
public sealed class MigrationExecutionTests
|
|
{
|
|
[Fact]
|
|
public async Task Api_test_database_uses_postgresql_and_applies_every_migration()
|
|
{
|
|
await using var factory = new ApiTestFactory();
|
|
using var scope = factory.Services.CreateScope();
|
|
var dbContext = scope.ServiceProvider.GetRequiredService<TikuDbContext>();
|
|
|
|
var appliedMigrations = await dbContext.Database.GetAppliedMigrationsAsync();
|
|
var expectedMigrations = dbContext.Database.GetMigrations();
|
|
|
|
Assert.Equal("Npgsql.EntityFrameworkCore.PostgreSQL", dbContext.Database.ProviderName);
|
|
Assert.Equal(expectedMigrations, appliedMigrations);
|
|
Assert.NotEmpty(appliedMigrations);
|
|
Assert.True(await dbContext.Database.CanConnectAsync());
|
|
}
|
|
}
|