live_beats/test/live_beats/accounts_test.exs

34 lines
836 B
Elixir
Raw Permalink Normal View History

2021-09-08 14:58:32 +00:00
defmodule LiveBeats.AccountsTest do
use LiveBeats.DataCase
import LiveBeats.AccountsFixtures
2021-12-14 15:35:51 +00:00
alias LiveBeats.Accounts
2021-09-08 14:58:32 +00:00
describe "get_user!/1" do
test "raises if id is invalid" do
assert_raise Ecto.NoResultsError, fn ->
Accounts.get_user!(-1)
end
end
test "returns the user with the given id" do
%{id: id} = user = user_fixture()
2021-12-14 15:35:51 +00:00
assert %Accounts.User{id: ^id} = Accounts.get_user!(user.id)
2021-09-08 14:58:32 +00:00
end
end
describe "register_github_user/1" do
test "creates users with valid data" do
2021-12-14 15:35:51 +00:00
info = %{
"id" => "github-id",
"login" => "Chrismccord",
2021-12-14 15:35:51 +00:00
"avatar_url" => "https://example.com",
"html_url" => "https://example.com"
}
assert {:ok, _user} = Accounts.register_github_user("chris@example.com", info, [], "123")
2021-09-08 14:58:32 +00:00
end
end
end