Testing an Ecto Schema for Database Interactions
The most common use case for Ecto schemas is to enable easy interaction with a database. While we keep our schemas to a minimum of logic—just the schema definition and changeset function or functions—we still need to make some changes in order to use our schema with a database. We’ll update the basic schema we wrote (skipping the changes we made for using it as a validator) and then update our tests. Once we’ve covered the schema aspects, we’ll move on to cover testing queries that use the schema.
Adding a Database into Our Application
Before we can make the necessary changes, we need to make sure that we have a local running database. Given that every reader will have a different local setup, ...
Get Testing Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.