October 2019
Intermediate to advanced
358 pages
8h 22m
English
It’s time to test the M of the MVC, models. Phoenix generates a module in test/support/data_case.ex to serve as a foundation for your tests that interact with the database. In our case, Accounts and Multimedia contexts both work with the database. The data_case handles setup and teardown of the database and integrates with Ecto.Sandbox to allow concurrent transactional tests. Crack it open and import the fixtures we just defined:
| 1: | defmodule Rumbl.DataCase do |
| - | use ExUnit.CaseTemplate |
| - | |
| - | using do |
| 5: | quote do |
| - | alias Rumbl.Repo |
| - | |
| - | import Ecto |
| - | import Ecto.Changeset |
| 10: | import Ecto.Query |
| - | import Rumbl.DataCase |
| - | import Rumbl.TestHelpers ... |
Read now
Unlock full access