live_beats/test/support/fixtures/media_library_fixtures.ex

37 lines
923 B
Elixir
Raw Normal View History

2021-10-29 16:12:23 +00:00
defmodule LiveBeats.MediaLibraryFixtures do
@moduledoc """
This module defines test helpers for creating
entities via the `LiveBeats.MediaLibrary` context.
"""
2021-12-14 15:35:51 +00:00
alias LiveBeats.MediaLibrary.Song
2021-10-29 16:12:23 +00:00
@doc """
Generate a song.
"""
def song_fixture(attrs \\ %{}) do
2022-01-31 13:41:34 +00:00
{:ok, server_ip} = EctoNetwork.INET.cast(LiveBeats.config([:files, :server_ip]))
2021-10-29 16:12:23 +00:00
{:ok, song} =
2021-12-14 15:35:51 +00:00
struct!(
Song,
Enum.into(attrs, %{
album_artist: "some album_artist",
artist: "some artist",
date_recorded: ~N[2021-10-26 20:11:00],
date_released: ~N[2021-10-26 20:11:00],
duration: 42,
title: "some title",
mp3_url: "//example.com/mp3.mp3",
mp3_filename: "mp3.mp3",
mp3_filepath: "/data/mp3.mp3",
2022-01-31 13:41:34 +00:00
server_ip: server_ip,
2021-12-14 15:35:51 +00:00
status: :stopped
})
)
|> LiveBeats.Repo.insert()
2021-10-29 16:12:23 +00:00
song
end
end