Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

Testing interactions with the repository separately

We'll now explore how to run the tests that interact with the application's repository separately. At the beginning of this chapter, we created some tests for the %Media{} struct, and seen how we can test the changeset logic without ever touching the database. Now, we'll see how to actually run the tests that hit the database.

A common question that's asked every once in a while is how to create a mock for the repository, so that we can test the functions that interact with it independently. While the repository is indeed another dependency, we think that creating a mock for it makes no sense, because in the repository tests, we want to verify that our commands and queries work as expected. ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content