philomena/test/philomena/conversations_test.exs
2019-08-28 12:48:39 -04:00

62 lines
2.2 KiB
Elixir

defmodule Philomena.ConversationsTest do
use Philomena.DataCase
alias Philomena.Conversations
describe "conversations" do
alias Philomena.Conversations.Conversation
@valid_attrs %{}
@update_attrs %{}
@invalid_attrs %{}
def conversation_fixture(attrs \\ %{}) do
{:ok, conversation} =
attrs
|> Enum.into(@valid_attrs)
|> Conversations.create_conversation()
conversation
end
test "list_conversations/0 returns all conversations" do
conversation = conversation_fixture()
assert Conversations.list_conversations() == [conversation]
end
test "get_conversation!/1 returns the conversation with given id" do
conversation = conversation_fixture()
assert Conversations.get_conversation!(conversation.id) == conversation
end
test "create_conversation/1 with valid data creates a conversation" do
assert {:ok, %Conversation{} = conversation} = Conversations.create_conversation(@valid_attrs)
end
test "create_conversation/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Conversations.create_conversation(@invalid_attrs)
end
test "update_conversation/2 with valid data updates the conversation" do
conversation = conversation_fixture()
assert {:ok, %Conversation{} = conversation} = Conversations.update_conversation(conversation, @update_attrs)
end
test "update_conversation/2 with invalid data returns error changeset" do
conversation = conversation_fixture()
assert {:error, %Ecto.Changeset{}} = Conversations.update_conversation(conversation, @invalid_attrs)
assert conversation == Conversations.get_conversation!(conversation.id)
end
test "delete_conversation/1 deletes the conversation" do
conversation = conversation_fixture()
assert {:ok, %Conversation{}} = Conversations.delete_conversation(conversation)
assert_raise Ecto.NoResultsError, fn -> Conversations.get_conversation!(conversation.id) end
end
test "change_conversation/1 returns a conversation changeset" do
conversation = conversation_fixture()
assert %Ecto.Changeset{} = Conversations.change_conversation(conversation)
end
end
end