Writing session controller tests

As with the previous examples, we don't want to just leave our functionality here. We want to make sure that we're covering everything we write with an adequate amount of tests, so we'll need to write new tests for the session controller functions that we've added and the additional function in our accounts context. That will actually be the easiest one to write the tests for, so we'll start off with that one. Return over to test/vocial/accounts/accounts_test.exs and let's add a test for get_user_by_username\1. We'll start off with the positive case:

    test "get_user_by_username/1 returns the user with the matching username" do      user = user_fixture()      assert Accounts.get_user_by_username(user.username)    end

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.