Skip to content

Commit

Permalink
fixup 3 - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Nov 28, 2024
1 parent 32eea88 commit 06b9233
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
4 changes: 2 additions & 2 deletions lib/radiator/outline/node_repository.ex
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ defmodule Radiator.Outline.NodeRepository do
def create_nodes_for_show(show_id) do
# create a root node for a show
{:ok, show_root} =
NodeRepository.create_node(%{
create_node(%{
show_id: show_id,
parent_id: nil,
prev_id: nil,
_type: "global_root"
})

{:ok, global_inbox} =
NodeRepository.create_node(%{
create_node(%{
show_id: show_id,
parent_id: show_root.uuid,
prev_id: nil,
Expand Down
24 changes: 11 additions & 13 deletions lib/radiator/podcast.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule Radiator.Podcast do
import Ecto.Query, warn: false
alias Radiator.Repo

alias Radiator.Outline.NodeRepository
alias Radiator.Podcast.{Episode, Network, Show, ShowHosts}

@doc """
Expand Down Expand Up @@ -183,19 +184,16 @@ defmodule Radiator.Podcast do
"""
def create_show(attrs \\ %{}) do
# also need to create the nodes for the show
# start a transaction
result =
Repo.transaction(fn ->
show =
%Show{}
|> Show.changeset(attrs)
|> Repo.insert()

{_show_root, _global_inbox} = NodeRepository.create_nodes_for_show(show.id)
end)

IO.inspect(result, label: "result")
result
# start a transaction =
Repo.transaction(fn ->
{:ok, show} =
%Show{}
|> Show.changeset(attrs)
|> Repo.insert()

{_show_root, _global_inbox} = NodeRepository.create_nodes_for_show(show.id)
show
end)
end

@doc """
Expand Down
12 changes: 6 additions & 6 deletions test/support/fixtures/podcast_fixtures.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ defmodule Radiator.PodcastFixtures do
Generate a show.
"""
def show_fixture(attrs \\ %{}, hosts \\ []) do
network = get_network(attrs)
network = extract_network(attrs)

{:ok, show} =
attrs
Expand All @@ -40,7 +40,7 @@ defmodule Radiator.PodcastFixtures do
Generate a episode.
"""
def episode_fixture(attrs \\ %{}) do
show = get_show(attrs)
show = extract_show(attrs)
number = Podcast.get_next_episode_number(show.id)

{:ok, episode} =
Expand All @@ -55,9 +55,9 @@ defmodule Radiator.PodcastFixtures do
episode
end

defp get_network(%{network_id: id}), do: Podcast.get_network!(id)
defp get_network(_), do: network_fixture()
defp extract_network(%{network_id: id}), do: Podcast.get_network!(id)
defp extract_network(_), do: network_fixture()

defp get_show(%{show_id: id}), do: Podcast.get_show!(id)
defp get_show(_), do: show_fixture()
defp extract_show(%{show_id: id}), do: Podcast.get_show!(id)
defp extract_show(_), do: show_fixture()
end

0 comments on commit 06b9233

Please sign in to comment.