Skip to content

Commit

Permalink
include associations to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Dec 11, 2023
1 parent f0ff9a1 commit 5b9ec4b
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/radiator/podcasts_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,12 @@ defmodule Radiator.PodcastsTest do
end

test "create_podcast/1 with valid data creates a podcast" do
valid_attrs = %{title: "some title", hostname: "some hostname"}
station = station_fixture()
valid_attrs = %{title: "some title", station_id: station.id}

assert {:ok, %Podcast{} = podcast} = Podcasts.create_podcast(valid_attrs)
assert podcast.title == "some title"
assert podcast.hostname == "some hostname"
assert podcast.station_id == station.id
end

test "create_podcast/1 with invalid data returns error changeset" do
Expand All @@ -87,11 +88,12 @@ defmodule Radiator.PodcastsTest do

test "update_podcast/2 with valid data updates the podcast" do
podcast = podcast_fixture()
update_attrs = %{title: "some updated title", hostname: "some updated hostname"}
updated_station = station_fixture()
update_attrs = %{title: "some updated title", station_id: updated_station.id}

assert {:ok, %Podcast{} = podcast} = Podcasts.update_podcast(podcast, update_attrs)
assert podcast.title == "some updated title"
assert podcast.hostname == "some updated hostname"
assert podcast.station_id == updated_station.id
end

test "update_podcast/2 with invalid data returns error changeset" do
Expand Down Expand Up @@ -135,6 +137,7 @@ defmodule Radiator.PodcastsTest do

assert {:ok, %Episode{} = episode} = Podcasts.create_episode(valid_attrs)
assert episode.title == "some title"
assert episode.podcast_id == podcast.id
end

test "create_episode/1 with invalid data returns error changeset" do
Expand All @@ -143,10 +146,12 @@ defmodule Radiator.PodcastsTest do

test "update_episode/2 with valid data updates the episode" do
episode = episode_fixture()
update_attrs = %{title: "some updated title"}
updated_podcast = podcast_fixture()
update_attrs = %{title: "some updated title", podcast_id: updated_podcast.id}

assert {:ok, %Episode{} = episode} = Podcasts.update_episode(episode, update_attrs)
assert episode.title == "some updated title"
assert episode.podcast_id == updated_podcast.id
end

test "update_episode/2 with invalid data returns error changeset" do
Expand Down

0 comments on commit 5b9ec4b

Please sign in to comment.