Shoring up our tests

Next, we can move on to actually writing our tests. We'll want to test two things, specifically:

  1. When we have multiple polls, we want to return them in the order of most-recently created to least-recently created.
  2. When we are including pagination params (page and per_page), we should get the correct results (also respecting ordering).

We'll start with a test to cover the first scenario, since that should be pretty simple to write:

test "list_most_recent_polls/2 returns polls ordered by the most recent first", %{user: user} do  poll = poll_fixture(%{user_id: user.id})  poll2 = poll_fixture(%{user_id: user.id})  poll3 = poll_fixture(%{user_id: user.id})  assert Votes.list_most_recent_polls() == [poll3, poll2, poll]end

What ...

Get Phoenix Web Development 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.