Acceptable Upgrades
summary
Legacy DB forces tests to use a full production dump so initial tests require at least 18 records and run painfully slow. The remedy is concrete: draw the schema, enforce module boundaries with Boundary library (Sashi Yurika) so code forms a DAG, move Ecto schemas into their own namespace, prefer functional composition for fixtures, and mock only external services while calling prod code in tests. Tools used include Phoenix, Ecto, ExMachina and LiveView test helpers; result is rapid, incremental tests and safer refactors without changing the legacy schema.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 2:18Schema dependencies
- 5:49Clean code boundaries
- 8:56Namespaces and buckets
- 12:05Minimal test dependencies
- 14:51Syntactic sugar in testing
- 16:36Functional core contexts
- 18:45Ecto schemas vs mutations
- 20:33Functional query composition
- 23:24Ecto.Query rules and tests
- 25:10Test data with relationships
- 27:41Closing thoughts and further exploration
related talks
54mTesting in Legacy: From Rags to Riches
39mPainless Test Driven Development with Elixir and Phoenix
34mTesting legacy code when you dislike tests (and legacy code)
01h 00mTesting Heresies
50mAdam Furmanek: You Must Test Your Databases And Here Is How
28mAdvanced Testing Techniques
41mLegacy, for lack of a better word, is good
46mBetter code through boring(er) tests
