2017-12-08 09:58:14 +01:00
|
|
|
defmodule Eventos.EventsTest do
|
|
|
|
use Eventos.DataCase
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
import Eventos.Factory
|
|
|
|
|
2017-12-08 09:58:14 +01:00
|
|
|
alias Eventos.Events
|
2018-06-14 17:25:55 +02:00
|
|
|
alias Eventos.Actors
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
@event_valid_attrs %{
|
|
|
|
begins_on: "2010-04-17 14:00:00.000000Z",
|
|
|
|
description: "some description",
|
|
|
|
ends_on: "2010-04-17 14:00:00.000000Z",
|
|
|
|
title: "some title"
|
|
|
|
}
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-06-14 17:25:55 +02:00
|
|
|
def actor_fixture do
|
|
|
|
insert(:actor)
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-01-17 11:39:01 +01:00
|
|
|
def address_fixture do
|
|
|
|
insert(:address)
|
|
|
|
end
|
|
|
|
|
2018-01-14 17:56:50 +01:00
|
|
|
def event_fixture do
|
2018-01-17 11:39:01 +01:00
|
|
|
insert(:event)
|
2018-01-13 23:33:03 +01:00
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-01-15 12:04:09 +01:00
|
|
|
def category_fixture do
|
|
|
|
insert(:category)
|
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
describe "events" do
|
|
|
|
alias Eventos.Events.Event
|
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
@valid_attrs %{
|
|
|
|
begins_on: "2010-04-17 14:00:00.000000Z",
|
|
|
|
description: "some description",
|
|
|
|
ends_on: "2010-04-17 14:00:00.000000Z",
|
|
|
|
title: "some title"
|
|
|
|
}
|
|
|
|
@update_attrs %{
|
|
|
|
begins_on: "2011-05-18 15:01:01.000000Z",
|
|
|
|
description: "some updated description",
|
|
|
|
ends_on: "2011-05-18 15:01:01.000000Z",
|
|
|
|
title: "some updated title"
|
|
|
|
}
|
2018-01-13 23:33:03 +01:00
|
|
|
@invalid_attrs %{begins_on: nil, description: nil, ends_on: nil, title: nil}
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
test "list_events/0 returns all events" do
|
|
|
|
event = event_fixture()
|
2018-01-13 23:33:03 +01:00
|
|
|
assert hd(Events.list_events()).title == event.title
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
test "get_event!/1 returns the event with given id" do
|
|
|
|
event = event_fixture()
|
2018-01-13 23:33:03 +01:00
|
|
|
assert Events.get_event!(event.id).title == event.title
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
test "create_event/1 with valid data creates a event" do
|
2018-06-14 17:25:55 +02:00
|
|
|
actor = actor_fixture()
|
2018-01-15 12:04:09 +01:00
|
|
|
category = category_fixture()
|
2018-01-17 11:39:01 +01:00
|
|
|
address = address_fixture()
|
2018-07-27 10:45:35 +02:00
|
|
|
|
|
|
|
valid_attrs =
|
|
|
|
@event_valid_attrs
|
2018-06-14 17:25:55 +02:00
|
|
|
|> Map.put(:organizer_actor, actor)
|
|
|
|
|> Map.put(:organizer_actor_id, actor.id)
|
2018-01-17 11:39:01 +01:00
|
|
|
|> Map.put(:category_id, category.id)
|
|
|
|
|> Map.put(:address_id, address.id)
|
2018-07-27 10:45:35 +02:00
|
|
|
|
2018-01-17 11:39:01 +01:00
|
|
|
assert {:ok, %Event{} = event} = Events.create_event(valid_attrs)
|
2018-01-13 23:33:03 +01:00
|
|
|
assert event.begins_on == DateTime.from_naive!(~N[2010-04-17 14:00:00.000000Z], "Etc/UTC")
|
2017-12-08 09:58:14 +01:00
|
|
|
assert event.description == "some description"
|
|
|
|
assert event.ends_on == DateTime.from_naive!(~N[2010-04-17 14:00:00.000000Z], "Etc/UTC")
|
|
|
|
assert event.title == "some title"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_event/1 with invalid data returns error changeset" do
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.create_event(@invalid_attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_event/2 with valid data updates the event" do
|
|
|
|
event = event_fixture()
|
|
|
|
assert {:ok, event} = Events.update_event(event, @update_attrs)
|
|
|
|
assert %Event{} = event
|
2018-01-13 23:33:03 +01:00
|
|
|
assert event.begins_on == DateTime.from_naive!(~N[2011-05-18 15:01:01.000000Z], "Etc/UTC")
|
2017-12-08 09:58:14 +01:00
|
|
|
assert event.description == "some updated description"
|
|
|
|
assert event.ends_on == DateTime.from_naive!(~N[2011-05-18 15:01:01.000000Z], "Etc/UTC")
|
|
|
|
assert event.title == "some updated title"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_event/2 with invalid data returns error changeset" do
|
|
|
|
event = event_fixture()
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.update_event(event, @invalid_attrs)
|
2018-01-13 23:33:03 +01:00
|
|
|
assert event.title == Events.get_event!(event.id).title
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
test "delete_event/1 deletes the event" do
|
|
|
|
event = event_fixture()
|
|
|
|
assert {:ok, %Event{}} = Events.delete_event(event)
|
|
|
|
assert_raise Ecto.NoResultsError, fn -> Events.get_event!(event.id) end
|
|
|
|
end
|
|
|
|
|
|
|
|
test "change_event/1 returns a event changeset" do
|
|
|
|
event = event_fixture()
|
|
|
|
assert %Ecto.Changeset{} = Events.change_event(event)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "categories" do
|
|
|
|
alias Eventos.Events.Category
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
@valid_attrs %{description: "some description", picture: "some picture", title: "some title"}
|
2018-07-27 10:45:35 +02:00
|
|
|
@update_attrs %{
|
|
|
|
description: "some updated description",
|
|
|
|
picture: "some updated picture",
|
|
|
|
title: "some updated title"
|
|
|
|
}
|
2018-01-13 23:33:03 +01:00
|
|
|
@invalid_attrs %{description: nil, picture: nil, title: nil}
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
test "list_categories/0 returns all categories" do
|
|
|
|
category = category_fixture()
|
|
|
|
assert Events.list_categories() == [category]
|
|
|
|
end
|
|
|
|
|
|
|
|
test "get_category!/1 returns the category with given id" do
|
|
|
|
category = category_fixture()
|
|
|
|
assert Events.get_category!(category.id) == category
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_category/1 with valid data creates a category" do
|
|
|
|
assert {:ok, %Category{} = category} = Events.create_category(@valid_attrs)
|
2018-01-13 23:33:03 +01:00
|
|
|
assert category.description == "some description"
|
2017-12-08 09:58:14 +01:00
|
|
|
assert category.picture == "some picture"
|
|
|
|
assert category.title == "some title"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_category/1 with invalid data returns error changeset" do
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.create_category(@invalid_attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_category/2 with valid data updates the category" do
|
|
|
|
category = category_fixture()
|
|
|
|
assert {:ok, category} = Events.update_category(category, @update_attrs)
|
|
|
|
assert %Category{} = category
|
2018-01-13 23:33:03 +01:00
|
|
|
assert category.description == "some updated description"
|
2017-12-08 09:58:14 +01:00
|
|
|
assert category.picture == "some updated picture"
|
|
|
|
assert category.title == "some updated title"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_category/2 with invalid data returns error changeset" do
|
|
|
|
category = category_fixture()
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.update_category(category, @invalid_attrs)
|
|
|
|
assert category == Events.get_category!(category.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "delete_category/1 deletes the category" do
|
|
|
|
category = category_fixture()
|
|
|
|
assert {:ok, %Category{}} = Events.delete_category(category)
|
|
|
|
assert_raise Ecto.NoResultsError, fn -> Events.get_category!(category.id) end
|
|
|
|
end
|
|
|
|
|
|
|
|
test "change_category/1 returns a category changeset" do
|
|
|
|
category = category_fixture()
|
|
|
|
assert %Ecto.Changeset{} = Events.change_category(category)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "tags" do
|
|
|
|
alias Eventos.Events.Tag
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
@valid_attrs %{title: "some title"}
|
|
|
|
@update_attrs %{title: "some updated title"}
|
|
|
|
@invalid_attrs %{title: nil}
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
def tag_fixture(attrs \\ %{}) do
|
|
|
|
{:ok, tag} =
|
|
|
|
attrs
|
|
|
|
|> Enum.into(@valid_attrs)
|
|
|
|
|> Events.create_tag()
|
|
|
|
|
|
|
|
tag
|
|
|
|
end
|
|
|
|
|
|
|
|
test "list_tags/0 returns all tags" do
|
|
|
|
tag = tag_fixture()
|
|
|
|
assert Events.list_tags() == [tag]
|
|
|
|
end
|
|
|
|
|
|
|
|
test "get_tag!/1 returns the tag with given id" do
|
|
|
|
tag = tag_fixture()
|
|
|
|
assert Events.get_tag!(tag.id) == tag
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_tag/1 with valid data creates a tag" do
|
|
|
|
assert {:ok, %Tag{} = tag} = Events.create_tag(@valid_attrs)
|
|
|
|
assert tag.title == "some title"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_tag/1 with invalid data returns error changeset" do
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.create_tag(@invalid_attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_tag/2 with valid data updates the tag" do
|
|
|
|
tag = tag_fixture()
|
|
|
|
assert {:ok, tag} = Events.update_tag(tag, @update_attrs)
|
|
|
|
assert %Tag{} = tag
|
|
|
|
assert tag.title == "some updated title"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_tag/2 with invalid data returns error changeset" do
|
|
|
|
tag = tag_fixture()
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.update_tag(tag, @invalid_attrs)
|
|
|
|
assert tag == Events.get_tag!(tag.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "delete_tag/1 deletes the tag" do
|
|
|
|
tag = tag_fixture()
|
|
|
|
assert {:ok, %Tag{}} = Events.delete_tag(tag)
|
|
|
|
assert_raise Ecto.NoResultsError, fn -> Events.get_tag!(tag.id) end
|
|
|
|
end
|
|
|
|
|
|
|
|
test "change_tag/1 returns a tag changeset" do
|
|
|
|
tag = tag_fixture()
|
|
|
|
assert %Ecto.Changeset{} = Events.change_tag(tag)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
describe "participants" do
|
|
|
|
alias Eventos.Events.Participant
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
@valid_attrs %{role: 42}
|
|
|
|
@update_attrs %{role: 43}
|
|
|
|
@invalid_attrs %{role: nil}
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
def participant_fixture(attrs \\ %{}) do
|
|
|
|
event = event_fixture()
|
2018-06-14 17:25:55 +02:00
|
|
|
actor = actor_fixture()
|
2018-01-13 23:33:03 +01:00
|
|
|
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
2018-06-14 17:25:55 +02:00
|
|
|
valid_attrs = Map.put(valid_attrs, :actor_id, actor.id)
|
2018-07-27 10:45:35 +02:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
{:ok, participant} =
|
2017-12-08 09:58:14 +01:00
|
|
|
attrs
|
2018-01-13 23:33:03 +01:00
|
|
|
|> Enum.into(valid_attrs)
|
|
|
|
|> Events.create_participant()
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
participant
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
test "list_participants/0 returns all participants" do
|
|
|
|
participant = participant_fixture()
|
|
|
|
assert Events.list_participants() == [participant]
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
# test "get_participant!/1 returns the participant with given id" do
|
|
|
|
# participant = participant_fixture()
|
|
|
|
# assert Events.get_participant!(participant.id) == participant
|
|
|
|
# end
|
2017-12-08 09:58:14 +01:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
test "create_participant/1 with valid data creates a participant" do
|
2018-06-14 17:25:55 +02:00
|
|
|
actor = actor_fixture()
|
2018-01-13 23:33:03 +01:00
|
|
|
event = event_fixture()
|
|
|
|
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
2018-06-14 17:25:55 +02:00
|
|
|
valid_attrs = Map.put(valid_attrs, :actor_id, actor.id)
|
2018-01-13 23:33:03 +01:00
|
|
|
assert {:ok, %Participant{} = participant} = Events.create_participant(valid_attrs)
|
|
|
|
assert participant.role == 42
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
test "create_participant/1 with invalid data returns error changeset" do
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.create_participant(@invalid_attrs)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
test "update_participant/2 with valid data updates the participant" do
|
|
|
|
participant = participant_fixture()
|
|
|
|
assert {:ok, participant} = Events.update_participant(participant, @update_attrs)
|
|
|
|
assert %Participant{} = participant
|
|
|
|
assert participant.role == 43
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
test "update_participant/2 with invalid data returns error changeset" do
|
|
|
|
participant = participant_fixture()
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.update_participant(participant, @invalid_attrs)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
test "delete_participant/1 deletes the participant" do
|
|
|
|
participant = participant_fixture()
|
|
|
|
assert {:ok, %Participant{}} = Events.delete_participant(participant)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
test "change_participant/1 returns a participant changeset" do
|
|
|
|
participant = participant_fixture()
|
|
|
|
assert %Ecto.Changeset{} = Events.change_participant(participant)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
describe "sessions" do
|
|
|
|
alias Eventos.Events.Session
|
|
|
|
|
2018-07-27 10:45:35 +02:00
|
|
|
@valid_attrs %{
|
|
|
|
audios_urls: "some audios_urls",
|
|
|
|
language: "some language",
|
|
|
|
long_abstract: "some long_abstract",
|
|
|
|
short_abstract: "some short_abstract",
|
|
|
|
slides_url: "some slides_url",
|
|
|
|
subtitle: "some subtitle",
|
|
|
|
title: "some title",
|
|
|
|
videos_urls: "some videos_urls"
|
|
|
|
}
|
|
|
|
@update_attrs %{
|
|
|
|
audios_urls: "some updated audios_urls",
|
|
|
|
language: "some updated language",
|
|
|
|
long_abstract: "some updated long_abstract",
|
|
|
|
short_abstract: "some updated short_abstract",
|
|
|
|
slides_url: "some updated slides_url",
|
|
|
|
subtitle: "some updated subtitle",
|
|
|
|
title: "some updated title",
|
|
|
|
videos_urls: "some updated videos_urls"
|
|
|
|
}
|
|
|
|
@invalid_attrs %{
|
|
|
|
audios_urls: nil,
|
|
|
|
language: nil,
|
|
|
|
long_abstract: nil,
|
|
|
|
short_abstract: nil,
|
|
|
|
slides_url: nil,
|
|
|
|
subtitle: nil,
|
|
|
|
title: nil,
|
|
|
|
videos_urls: nil
|
|
|
|
}
|
2018-01-13 23:33:03 +01:00
|
|
|
|
|
|
|
def session_fixture(attrs \\ %{}) do
|
|
|
|
event = event_fixture()
|
|
|
|
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
2018-07-27 10:45:35 +02:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
{:ok, session} =
|
|
|
|
attrs
|
|
|
|
|> Enum.into(valid_attrs)
|
|
|
|
|> Events.create_session()
|
|
|
|
|
|
|
|
session
|
|
|
|
end
|
|
|
|
|
|
|
|
test "list_sessions/0 returns all sessions" do
|
|
|
|
session = session_fixture()
|
|
|
|
assert Events.list_sessions() == [session]
|
|
|
|
end
|
|
|
|
|
|
|
|
test "get_session!/1 returns the session with given id" do
|
|
|
|
session = session_fixture()
|
|
|
|
assert Events.get_session!(session.id) == session
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_session/1 with valid data creates a session" do
|
|
|
|
event = event_fixture()
|
|
|
|
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
|
|
|
assert {:ok, %Session{} = session} = Events.create_session(valid_attrs)
|
|
|
|
assert session.audios_urls == "some audios_urls"
|
|
|
|
assert session.language == "some language"
|
|
|
|
assert session.long_abstract == "some long_abstract"
|
|
|
|
assert session.short_abstract == "some short_abstract"
|
|
|
|
assert session.slides_url == "some slides_url"
|
|
|
|
assert session.subtitle == "some subtitle"
|
|
|
|
assert session.title == "some title"
|
|
|
|
assert session.videos_urls == "some videos_urls"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_session/1 with invalid data returns error changeset" do
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.create_session(@invalid_attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_session/2 with valid data updates the session" do
|
|
|
|
session = session_fixture()
|
|
|
|
assert {:ok, session} = Events.update_session(session, @update_attrs)
|
|
|
|
assert %Session{} = session
|
|
|
|
assert session.audios_urls == "some updated audios_urls"
|
|
|
|
assert session.language == "some updated language"
|
|
|
|
assert session.long_abstract == "some updated long_abstract"
|
|
|
|
assert session.short_abstract == "some updated short_abstract"
|
|
|
|
assert session.slides_url == "some updated slides_url"
|
|
|
|
assert session.subtitle == "some updated subtitle"
|
|
|
|
assert session.title == "some updated title"
|
|
|
|
assert session.videos_urls == "some updated videos_urls"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_session/2 with invalid data returns error changeset" do
|
|
|
|
session = session_fixture()
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.update_session(session, @invalid_attrs)
|
|
|
|
assert session == Events.get_session!(session.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "delete_session/1 deletes the session" do
|
|
|
|
session = session_fixture()
|
|
|
|
assert {:ok, %Session{}} = Events.delete_session(session)
|
|
|
|
assert_raise Ecto.NoResultsError, fn -> Events.get_session!(session.id) end
|
|
|
|
end
|
|
|
|
|
|
|
|
test "change_session/1 returns a session changeset" do
|
|
|
|
session = session_fixture()
|
|
|
|
assert %Ecto.Changeset{} = Events.change_session(session)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "tracks" do
|
|
|
|
alias Eventos.Events.Track
|
|
|
|
|
|
|
|
@valid_attrs %{color: "some color", description: "some description", name: "some name"}
|
2018-07-27 10:45:35 +02:00
|
|
|
@update_attrs %{
|
|
|
|
color: "some updated color",
|
|
|
|
description: "some updated description",
|
|
|
|
name: "some updated name"
|
|
|
|
}
|
2018-01-13 23:33:03 +01:00
|
|
|
@invalid_attrs %{color: nil, description: nil, name: nil}
|
|
|
|
|
|
|
|
def track_fixture(attrs \\ %{}) do
|
|
|
|
event = event_fixture()
|
|
|
|
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
2018-07-27 10:45:35 +02:00
|
|
|
|
2018-01-13 23:33:03 +01:00
|
|
|
{:ok, track} =
|
|
|
|
attrs
|
|
|
|
|> Enum.into(valid_attrs)
|
|
|
|
|> Events.create_track()
|
|
|
|
|
|
|
|
track
|
|
|
|
end
|
|
|
|
|
|
|
|
test "list_tracks/0 returns all tracks" do
|
|
|
|
track = track_fixture()
|
|
|
|
assert Events.list_tracks() == [track]
|
|
|
|
end
|
|
|
|
|
|
|
|
test "get_track!/1 returns the track with given id" do
|
|
|
|
track = track_fixture()
|
|
|
|
assert Events.get_track!(track.id) == track
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_track/1 with valid data creates a track" do
|
|
|
|
event = event_fixture()
|
|
|
|
valid_attrs = Map.put(@valid_attrs, :event_id, event.id)
|
|
|
|
assert {:ok, %Track{} = track} = Events.create_track(valid_attrs)
|
|
|
|
assert track.color == "some color"
|
|
|
|
assert track.description == "some description"
|
|
|
|
assert track.name == "some name"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "create_track/1 with invalid data returns error changeset" do
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.create_track(@invalid_attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_track/2 with valid data updates the track" do
|
|
|
|
track = track_fixture()
|
|
|
|
assert {:ok, track} = Events.update_track(track, @update_attrs)
|
|
|
|
assert %Track{} = track
|
|
|
|
assert track.color == "some updated color"
|
|
|
|
assert track.description == "some updated description"
|
|
|
|
assert track.name == "some updated name"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_track/2 with invalid data returns error changeset" do
|
|
|
|
track = track_fixture()
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.update_track(track, @invalid_attrs)
|
|
|
|
assert track == Events.get_track!(track.id)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "delete_track/1 deletes the track" do
|
|
|
|
track = track_fixture()
|
|
|
|
assert {:ok, %Track{}} = Events.delete_track(track)
|
|
|
|
assert_raise Ecto.NoResultsError, fn -> Events.get_track!(track.id) end
|
|
|
|
end
|
|
|
|
|
|
|
|
test "change_track/1 returns a track changeset" do
|
|
|
|
track = track_fixture()
|
|
|
|
assert %Ecto.Changeset{} = Events.change_track(track)
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
end
|
2018-05-17 11:32:23 +02:00
|
|
|
|
|
|
|
describe "comments" do
|
|
|
|
alias Eventos.Events.Comment
|
|
|
|
|
2018-06-14 17:25:55 +02:00
|
|
|
@valid_attrs %{text: "some text"}
|
|
|
|
@update_attrs %{text: "some updated text"}
|
2018-05-17 11:32:23 +02:00
|
|
|
@invalid_attrs %{text: nil, url: nil}
|
|
|
|
|
2018-06-14 17:25:55 +02:00
|
|
|
def comment_fixture() do
|
|
|
|
insert(:comment)
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "list_comments/0 returns all comments" do
|
|
|
|
comment = comment_fixture()
|
2018-06-14 17:25:55 +02:00
|
|
|
comments = Events.list_comments()
|
|
|
|
assert comments = [comment]
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "get_comment!/1 returns the comment with given id" do
|
|
|
|
comment = comment_fixture()
|
2018-06-14 17:25:55 +02:00
|
|
|
comment_fetched = Events.get_comment!(comment.id)
|
|
|
|
assert comment_fetched = comment
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "create_comment/1 with valid data creates a comment" do
|
2018-06-14 17:25:55 +02:00
|
|
|
actor = actor_fixture()
|
|
|
|
comment_data = Map.merge(@valid_attrs, %{actor_id: actor.id})
|
|
|
|
assert {:ok, %Comment{} = comment} = Events.create_comment(comment_data)
|
2018-05-17 11:32:23 +02:00
|
|
|
assert comment.text == "some text"
|
2018-06-14 17:25:55 +02:00
|
|
|
assert comment.actor_id == actor.id
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "create_comment/1 with invalid data returns error changeset" do
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.create_comment(@invalid_attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_comment/2 with valid data updates the comment" do
|
|
|
|
comment = comment_fixture()
|
|
|
|
assert {:ok, comment} = Events.update_comment(comment, @update_attrs)
|
|
|
|
assert %Comment{} = comment
|
|
|
|
assert comment.text == "some updated text"
|
|
|
|
end
|
|
|
|
|
|
|
|
test "update_comment/2 with invalid data returns error changeset" do
|
|
|
|
comment = comment_fixture()
|
|
|
|
assert {:error, %Ecto.Changeset{}} = Events.update_comment(comment, @invalid_attrs)
|
2018-06-14 17:25:55 +02:00
|
|
|
comment_fetched = Events.get_comment!(comment.id)
|
|
|
|
assert comment = comment_fetched
|
2018-05-17 11:32:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
test "delete_comment/1 deletes the comment" do
|
|
|
|
comment = comment_fixture()
|
|
|
|
assert {:ok, %Comment{}} = Events.delete_comment(comment)
|
|
|
|
assert_raise Ecto.NoResultsError, fn -> Events.get_comment!(comment.id) end
|
|
|
|
end
|
|
|
|
|
|
|
|
test "change_comment/1 returns a comment changeset" do
|
|
|
|
comment = comment_fixture()
|
|
|
|
assert %Ecto.Changeset{} = Events.change_comment(comment)
|
|
|
|
end
|
|
|
|
end
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|