My space on the web https://inhji.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

68 lines
1.9 KiB

defmodule Mirage.ListsTest do
use Mirage.DataCase
alias Mirage.Lists
describe "lists" do
alias Mirage.Lists.List
@valid_attrs %{is_public: true, name: "some name"}
@update_attrs %{is_public: false, name: "some updated name"}
@invalid_attrs %{is_public: nil, name: nil}
def list_fixture(attrs \\ %{}) do
{:ok, list} =
attrs
|> Enum.into(@valid_attrs)
|> Lists.create_list()
list
|> Lists.preload_list()
end
test "list_lists/0 returns all lists" do
list = list_fixture()
assert Lists.list_lists() == [list]
end
test "get_list!/1 returns the list with given id" do
list = list_fixture()
assert Lists.get_list!(list.id) == list
end
test "create_list/1 with valid data creates a list" do
assert {:ok, %List{} = list} = Lists.create_list(@valid_attrs)
assert list.is_public == true
assert list.name == "some name"
end
test "create_list/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = Lists.create_list(@invalid_attrs)
end
test "update_list/2 with valid data updates the list" do
list = list_fixture()
assert {:ok, %List{} = list} = Lists.update_list(list, @update_attrs)
assert list.is_public == false
assert list.name == "some updated name"
end
test "update_list/2 with invalid data returns error changeset" do
list = list_fixture()
assert {:error, %Ecto.Changeset{}} = Lists.update_list(list, @invalid_attrs)
assert list == Lists.get_list!(list.id)
end
test "delete_list/1 deletes the list" do
list = list_fixture()
assert {:ok, %List{}} = Lists.delete_list(list)
assert_raise Ecto.NoResultsError, fn -> Lists.get_list!(list.id) end
end
test "change_list/1 returns a list changeset" do
list = list_fixture()
assert %Ecto.Changeset{} = Lists.change_list(list)
end
end
end