get started on route for creating links, dividing steps into components
This commit is contained in:
66
test/entendu/links_test.exs
Normal file
66
test/entendu/links_test.exs
Normal file
@@ -0,0 +1,66 @@
|
||||
defmodule Entendu.LinksTest do
|
||||
use Entendu.DataCase
|
||||
|
||||
alias Entendu.Links
|
||||
|
||||
describe "links" do
|
||||
alias Entendu.Links.Link
|
||||
|
||||
@valid_attrs %{burn_after_reading: true, expires: "2010-04-17T14:00:00Z"}
|
||||
@update_attrs %{burn_after_reading: false, expires: "2011-05-18T15:01:01Z"}
|
||||
@invalid_attrs %{burn_after_reading: nil, expires: nil}
|
||||
|
||||
def link_fixture(attrs \\ %{}) do
|
||||
{:ok, link} =
|
||||
attrs
|
||||
|> Enum.into(@valid_attrs)
|
||||
|> Links.create_link()
|
||||
|
||||
link
|
||||
end
|
||||
|
||||
test "list_links/0 returns all links" do
|
||||
link = link_fixture()
|
||||
assert Links.list_links() == [link]
|
||||
end
|
||||
|
||||
test "get_link!/1 returns the link with given id" do
|
||||
link = link_fixture()
|
||||
assert Links.get_link!(link.id) == link
|
||||
end
|
||||
|
||||
test "create_link/1 with valid data creates a link" do
|
||||
assert {:ok, %Link{} = link} = Links.create_link(@valid_attrs)
|
||||
assert link.burn_after_reading == true
|
||||
assert link.expires == DateTime.from_naive!(~N[2010-04-17T14:00:00Z], "Etc/UTC")
|
||||
end
|
||||
|
||||
test "create_link/1 with invalid data returns error changeset" do
|
||||
assert {:error, %Ecto.Changeset{}} = Links.create_link(@invalid_attrs)
|
||||
end
|
||||
|
||||
test "update_link/2 with valid data updates the link" do
|
||||
link = link_fixture()
|
||||
assert {:ok, %Link{} = link} = Links.update_link(link, @update_attrs)
|
||||
assert link.burn_after_reading == false
|
||||
assert link.expires == DateTime.from_naive!(~N[2011-05-18T15:01:01Z], "Etc/UTC")
|
||||
end
|
||||
|
||||
test "update_link/2 with invalid data returns error changeset" do
|
||||
link = link_fixture()
|
||||
assert {:error, %Ecto.Changeset{}} = Links.update_link(link, @invalid_attrs)
|
||||
assert link == Links.get_link!(link.id)
|
||||
end
|
||||
|
||||
test "delete_link/1 deletes the link" do
|
||||
link = link_fixture()
|
||||
assert {:ok, %Link{}} = Links.delete_link(link)
|
||||
assert_raise Ecto.NoResultsError, fn -> Links.get_link!(link.id) end
|
||||
end
|
||||
|
||||
test "change_link/1 returns a link changeset" do
|
||||
link = link_fixture()
|
||||
assert %Ecto.Changeset{} = Links.change_link(link)
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user