Seed backend endpoint test databases from a snapshot and align main with account#910
Open
tjementum wants to merge 1 commit into
Open
Seed backend endpoint test databases from a snapshot and align main with account#910tjementum wants to merge 1 commit into
tjementum wants to merge 1 commit into
Conversation
… main with account
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary & Motivation
Backend endpoint tests recreated the database schema with
EnsureCreated()and reran the fullDatabaseSeederon a fresh in-memory SQLite connection for every test. This change seeds the schema and fixtures once into a template database and fills each test's connection with a binary copy throughSqliteConnection.BackupDatabase, which is cheaper than recreating the schema and reseeding for every test.accountendpoint, back-office, and external-authentication base tests now restore from a shared seeded template (SeededDatabaseTemplate) instead of callingEnsureCreated()and reseeding per test. The template is seeded once through the real dependency injection graph so Entity Framework interceptors behave as in production, and a lock serializes the binary copies that feed each test.maintest infrastructure is brought to parity withaccount: a single host shared per test class (MainWebApplicationFactory, with per-test state carried through anAsyncLocalMainTestContext) plus the same snapshot seeding, replacing the previous per-test host rebuild. Themainsystem has no endpoint tests yet, so this establishes the shared pattern for the first one.accounthost was already shared per class, leaving only the per-test schema-create and reseed as headroom.Checklist