defmodule Philomena.ChannelsTest do use Philomena.DataCase alias Philomena.Channels describe "channels" do alias Philomena.Channels.Channel @valid_attrs %{} @update_attrs %{} @invalid_attrs %{} def channel_fixture(attrs \\ %{}) do {:ok, channel} = attrs |> Enum.into(@valid_attrs) |> Channels.create_channel() channel end test "list_channels/0 returns all channels" do channel = channel_fixture() assert Channels.list_channels() == [channel] end test "get_channel!/1 returns the channel with given id" do channel = channel_fixture() assert Channels.get_channel!(channel.id) == channel end test "create_channel/1 with valid data creates a channel" do assert {:ok, %Channel{} = channel} = Channels.create_channel(@valid_attrs) end test "create_channel/1 with invalid data returns error changeset" do assert {:error, %Ecto.Changeset{}} = Channels.create_channel(@invalid_attrs) end test "update_channel/2 with valid data updates the channel" do channel = channel_fixture() assert {:ok, %Channel{} = channel} = Channels.update_channel(channel, @update_attrs) end test "update_channel/2 with invalid data returns error changeset" do channel = channel_fixture() assert {:error, %Ecto.Changeset{}} = Channels.update_channel(channel, @invalid_attrs) assert channel == Channels.get_channel!(channel.id) end test "delete_channel/1 deletes the channel" do channel = channel_fixture() assert {:ok, %Channel{}} = Channels.delete_channel(channel) assert_raise Ecto.NoResultsError, fn -> Channels.get_channel!(channel.id) end end test "change_channel/1 returns a channel changeset" do channel = channel_fixture() assert %Ecto.Changeset{} = Channels.change_channel(channel) end end describe "channel_subscriptions" do alias Philomena.Channels.Subscription @valid_attrs %{} @update_attrs %{} @invalid_attrs %{} def subscription_fixture(attrs \\ %{}) do {:ok, subscription} = attrs |> Enum.into(@valid_attrs) |> Channels.create_subscription() subscription end test "list_channel_subscriptions/0 returns all channel_subscriptions" do subscription = subscription_fixture() assert Channels.list_channel_subscriptions() == [subscription] end test "get_subscription!/1 returns the subscription with given id" do subscription = subscription_fixture() assert Channels.get_subscription!(subscription.id) == subscription end test "create_subscription/1 with valid data creates a subscription" do assert {:ok, %Subscription{} = subscription} = Channels.create_subscription(@valid_attrs) end test "create_subscription/1 with invalid data returns error changeset" do assert {:error, %Ecto.Changeset{}} = Channels.create_subscription(@invalid_attrs) end test "update_subscription/2 with valid data updates the subscription" do subscription = subscription_fixture() assert {:ok, %Subscription{} = subscription} = Channels.update_subscription(subscription, @update_attrs) end test "update_subscription/2 with invalid data returns error changeset" do subscription = subscription_fixture() assert {:error, %Ecto.Changeset{}} = Channels.update_subscription(subscription, @invalid_attrs) assert subscription == Channels.get_subscription!(subscription.id) end test "delete_subscription/1 deletes the subscription" do subscription = subscription_fixture() assert {:ok, %Subscription{}} = Channels.delete_subscription(subscription) assert_raise Ecto.NoResultsError, fn -> Channels.get_subscription!(subscription.id) end end test "change_subscription/1 returns a subscription changeset" do subscription = subscription_fixture() assert %Ecto.Changeset{} = Channels.change_subscription(subscription) end end end