From 7bc350818cd001139aa39c78c2043bfeae3bbde4 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 12 Nov 2026 06:55:04 -0500 Subject: [PATCH] test(db): FlipAuditLogClusteredKey tests restore to head, expect migration 64's grant AuditMaintenanceGrants (migration 64) landed after the flip and adds GRANT UPDATE (SourceNode) to the purger, but the tests still migrated "back up" only to the flip and asserted the pre-64 grant list, so the class failed in either test order (the grant missing after DownUp, or unexpected before). Restore to head and compare the down state against the pre-64 grant set. Co-Authored-By: Claude --- .../FlipAuditLogClusteredKeyMigrationTests.cs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/tests/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests/Migrations/FlipAuditLogClusteredKeyMigrationTests.cs b/tests/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests/Migrations/FlipAuditLogClusteredKeyMigrationTests.cs index 8fac08a9..afbc9052 100644 --- a/tests/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests/Migrations/FlipAuditLogClusteredKeyMigrationTests.cs +++ b/tests/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase.Tests/Migrations/FlipAuditLogClusteredKeyMigrationTests.cs @@ -87,12 +87,14 @@ public sealed class FlipAuditLogClusteredKeyMigrationTests : IClassFixture !g.EndsWith("|SourceNode", StringComparison.Ordinal)).ToArray(); + private static void AssertTwelveNonClusteredIndexes(IReadOnlyDictionary indexes) { Assert.Equal("OccurredAtUtc DESC", indexes["IX_AuditLog_OccurredAtUtc"].Keys); @@ -252,6 +260,13 @@ FROM n;", conn) { CommandTimeout = 300 }; await ctx.GetService().MigrateAsync(migration); } + private async Task MigrateToHeadAsync() + { + await using var ctx = new ScadaBridgeDbContext(new DbContextOptionsBuilder() + .UseSqlServer(_fixture.ConnectionString, sql => sql.CommandTimeout(600)).Options); + await ctx.GetService().MigrateAsync(); + } + private static string MigrationBefore(string migration) { using var ctx = new ScadaBridgeDbContext(new DbContextOptionsBuilder()