test: extract and speed up db test helpers into atelier-testing library#341
Merged
test: extract and speed up db test helpers into atelier-testing library#341
Conversation
- Add new `atelier-testing` internal library with `Atelier.Testing.Database` - Share a single postgres server and template DB across the whole test process via a global `MVar`; sqitch migrations run exactly once - Use hspec's `runIO` for per-group DB setup combined with `around` for per-test truncation — eliminates `(unnamed)` groups in test output - Drop `TestConfig` wrapper; specs now receive `DBPools` directly - `Hoard.TestHelpers.Database` becomes a thin wrapper supplying hoard-specific config (roles, schema name, sqitch runner)
03a1d99 to
0c7ab85
Compare
Gipphe
approved these changes
Mar 19, 2026
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.
Shared postgres server + template database
● Before → After: 117 tests in ~10s → 0.56s
Previously each spec group started its own
TmpPostgresserver and ransqitchmigrations (~750ms × 8 groups). Now a single server starts in a background thread and migrations run once into a template database. Each spec group doesCREATE DATABASE ... TEMPLATEinstead which is near-instant.More info:
atelier-testinginternal library withAtelier.Testing.DatabaseMVar; sqitch migrations run exactly oncerunIOfor per-group DB setup combined witharoundfor per-test truncation — eliminates(unnamed)groups in test outputTestConfigwrapper; specs now receiveDBPoolsdirectlyHoard.TestHelpers.Databasebecomes a thin wrapper supplying hoard-specific config (roles, schema name, sqitch runner)