From ee700d49313d335a6fd143d9059ebd20c3505268 Mon Sep 17 00:00:00 2001 From: Heimdall Date: Sat, 14 Nov 2026 02:20:25 +0000 Subject: [PATCH] Test: snapshot has no drift from the design-time model (passes at base 425af74) Co-Authored-By: Claude Sonnet 5.5 --- tests/Bifrost.Web.Tests/SnapshotDriftTests.cs | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 tests/Bifrost.Web.Tests/SnapshotDriftTests.cs diff --git a/tests/Bifrost.Web.Tests/SnapshotDriftTests.cs b/tests/Bifrost.Web.Tests/SnapshotDriftTests.cs new file mode 100644 index 0000000..ce89dc4 --- /dev/null +++ b/tests/Bifrost.Web.Tests/SnapshotDriftTests.cs @@ -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().UseNpgsql("Host=unused").Options); + var snapshotModel = db.GetService().ModelSnapshot!.Model; + var designModel = db.GetService().Model; + var differ = db.GetService(); + + var differences = differ.GetDifferences( + db.GetService().Initialize(snapshotModel).GetRelationalModel(), + designModel.GetRelationalModel()); + + Assert.Empty(differences.Select(x => x.GetType().Name + ": " + x)); + } +}