pinchflat/test/support/fixtures/media_source_fixtures.ex
Kieran ca01f17b58
Start integrating playlist support (#13)
* [WIP] updated the output of VideoCollection to include playlists

* Updated source's name to collection_name; supported playlist ID/name fetching

* Hooked up collection_type to form; refactored enqueue_pending_media_downloads

* Added friendly_name to form

* Added media profile link to source view

* Updates comment
2024-02-05 11:38:19 -08:00

32 lines
943 B
Elixir

defmodule Pinchflat.MediaSourceFixtures do
@moduledoc """
This module defines test helpers for creating
entities via the `Pinchflat.MediaSource` context.
"""
alias Pinchflat.Repo
alias Pinchflat.ProfilesFixtures
alias Pinchflat.MediaSource.Source
@doc """
Generate a source.
"""
def source_fixture(attrs \\ %{}) do
{:ok, source} =
%Source{}
|> Source.changeset(
Enum.into(attrs, %{
collection_name: "Source ##{:rand.uniform(1_000_000)}",
collection_id: Base.encode16(:crypto.hash(:md5, "#{:rand.uniform(1_000_000)}")),
collection_type: "channel",
friendly_name: "Cool and good internal name!",
original_url: "https://www.youtube.com/channel/#{Faker.String.base64(12)}",
media_profile_id: ProfilesFixtures.media_profile_fixture().id,
index_frequency_minutes: 60
})
)
|> Repo.insert()
source
end
end