We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Testing and Refactoring Development Seeds in Phoenix and Ecto
69
clicks
Source: livinginthepast.org
The article discusses best practices for managing development seed data in Phoenix and Ecto applications. Initially, seed data is usually placed in `priv/repo/seeds.exs` as procedural code, making them vulnerable to breaking due to code refactors. Through examples, the article illustrates how to rewrite seed data as a module to allow for testing and better maintainability. This involves creating functions like `create_profile` and `create_org` within a module and altering the mix tasks to call these functions. The author provides a complete example including test cases to ensure seed data integrity after changes in the codebase. The distinction between development and production seeds is also highlighted to prevent potential issues during production deployments.
Related posts
© HashMerge 2024