feat: add migration export and write fencing
Some checks failed
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / pytest-smoke (push) Failing after 2s
Build and Publish Container Image / build-and-push (push) Successful in 19s

This commit is contained in:
tegwick 2026-08-21 17:07:53 +02:00
parent 9285a880be
commit f6758b91ce
10 changed files with 317 additions and 25 deletions

View file

@ -3,7 +3,7 @@ import json
from sqlalchemy import select
from sqlalchemy.ext.asyncio import async_sessionmaker
from core_hub.migration import import_bundle, validate_bundle
from core_hub.migration import export_bundle, import_bundle, validate_bundle
from core_hub.models import Hub, MigrationRun, Widget
@ -114,3 +114,24 @@ async def test_import_bundle_persists_records_and_run_summary(sqlite_engine):
second = await import_bundle(session, minimal_bundle())
assert second["counts"]["hubs"]["updated"] == 1
assert second["counts"]["interactionEvents"]["updated"] == 1
async def test_export_bundle_covers_all_source_tables_without_raw_keys(sqlite_engine):
sessionmaker = async_sessionmaker(sqlite_engine, expire_on_commit=False)
async with sessionmaker() as session:
await import_bundle(session, minimal_bundle())
bundle = await export_bundle(session, source_revision="source-revision")
assert set(bundle["records"]) == {
"hubs",
"hubCapabilityManifests",
"apiConsumers",
"apiKeys",
"widgets",
"interactionEvents",
"migrationRuns",
}
assert bundle["sourceRevision"] == "source-revision"
assert bundle["bundleSha256"]
assert bundle["records"]["apiKeys"][0]["keyHash"] == "a" * 64
assert "fullKey" not in json.dumps(bundle)