Bifrost/tests/Bifrost.Web.Tests/MigrationDiscoveryTests.cs
Heimdall 84ff2c4578 Account merge ledger: AccountMerge receipt, reductions, alias standing, undo and final sweep
AccountMergeLedger owns what a merge does to Bifrost records: PlanAsync (dry run, block codes),
CommitAsync (one save, total, idempotent), UndoLocalAsync (journal replay), FinalizeDueAsync
(AccountMergeSweeper) and StandingAsync/ResolveAsync. Votes and concept appraisals are voided by a
stamp that a model query filter hides from every tally. The actor accessor no longer ORs several
credentials under SingleOrDefault (a latent crash); a frozen or folded account resolves to no
account on every route, the OIDC authorize and chat refusal deny it, and patron intake follows the
alias. Migration AddAccountMerges is additive. No UI, no Heimdall call, nothing deployed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-14 02:31:51 +00:00

66 lines
2.4 KiB
C#

using Bifrost.Web.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Bifrost.Web.Tests;
public sealed class MigrationDiscoveryTests
{
private static readonly string[] ExpectedMigrations =
[
"20260422084653_InitialAlphaFoundation",
"20260608210000_AddHeimdallUserIdentity",
"20260609143000_AddPatronSupportDerivation",
"20260609160000_AddExternalPatronProviderIntake",
"20260617010537_AddBridgeActionLedger",
"20260617022305_AddAgentDispatchRuns",
"20260617033635_AddAgentTransportReceipts",
"20260617041417_AddGovernanceActivityReceipts",
"20260622142000_AddBridgeActionIdentityProvenance",
"20260622165000_AddBifrostNativeIdentity",
"20260622202000_AddBridgeActionTargetSurfaceName",
"20260705190000_AddPatronSupportProjectAttribution",
"20261010043937_AddConceptVotes",
"20261022163159_AddOpenIddict",
"20261109200000_AddSealedBallotMotions",
"20261109210000_AddMindKeys",
"20261111090000_AddConsentReceipts",
"20261111100000_ConsentReceiptsOneLivePerVersion",
"20261111110000_AddMembershipSuspensionReason",
"20261111120000_ClearLegacyConsentReceipts",
"20261113120000_AddPasskeyCredentials",
"20261114120000_AddAccountMerges",
];
// Database.GetMigrations() reads assembly metadata only; no connection is opened.
private static List<string> Discovered()
{
var options = new DbContextOptionsBuilder<BifrostDbContext>()
.UseNpgsql("Host=unused")
.Options;
using var db = new BifrostDbContext(options);
return db.Database.GetMigrations().ToList();
}
[Fact]
public void Every_migration_type_is_discovered()
{
var discovered = Discovered();
var declared = typeof(BifrostDbContext).Assembly.GetTypes()
.Where(t => !t.IsAbstract && typeof(Migration).IsAssignableFrom(t))
.ToList();
Assert.NotEmpty(declared);
Assert.Equal(declared.Count, discovered.Count);
foreach (var type in declared)
{
Assert.Contains(discovered, id => id.EndsWith("_" + type.Name, StringComparison.Ordinal));
}
}
[Fact]
public void All_migrations_are_listed_in_order()
{
Assert.Equal(ExpectedMigrations, Discovered());
}
}