Test: snapshot has no drift from the design-time model (passes at base 425af74)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
425af74500
commit
ee700d4931
1 changed files with 28 additions and 0 deletions
28
tests/Bifrost.Web.Tests/SnapshotDriftTests.cs
Normal file
28
tests/Bifrost.Web.Tests/SnapshotDriftTests.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Bifrost.Web.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Bifrost.Web.Tests;
|
||||
|
||||
public sealed class SnapshotDriftTests
|
||||
{
|
||||
// Migrations here are hand-written with a hand-edited snapshot, so the snapshot is compared with the model the app runs on:
|
||||
// a column or index the model has and the snapshot lacks would never reach a database.
|
||||
[Fact]
|
||||
public void The_model_snapshot_has_no_drift_from_the_design_time_model()
|
||||
{
|
||||
using var db = new BifrostDbContext(new DbContextOptionsBuilder<BifrostDbContext>().UseNpgsql("Host=unused").Options);
|
||||
var snapshotModel = db.GetService<IMigrationsAssembly>().ModelSnapshot!.Model;
|
||||
var designModel = db.GetService<IDesignTimeModel>().Model;
|
||||
var differ = db.GetService<IMigrationsModelDiffer>();
|
||||
|
||||
var differences = differ.GetDifferences(
|
||||
db.GetService<IModelRuntimeInitializer>().Initialize(snapshotModel).GetRelationalModel(),
|
||||
designModel.GetRelationalModel());
|
||||
|
||||
Assert.Empty(differences.Select(x => x.GetType().Name + ": " + x));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue