132 lines
5.0 KiB
Elixir
132 lines
5.0 KiB
Elixir
defmodule Bright.StreamsTest do
|
|
use Bright.DataCase
|
|
|
|
alias Bright.Streams
|
|
|
|
describe "streams" do
|
|
alias Bright.Streams.Stream
|
|
|
|
import Bright.StreamsFixtures
|
|
|
|
@invalid_attrs %{date: nil, title: nil, notes: nil}
|
|
|
|
test "list_streams/0 returns all streams" do
|
|
stream = stream_fixture()
|
|
assert Streams.list_streams() == [stream]
|
|
end
|
|
|
|
test "get_stream!/1 returns the stream with given id" do
|
|
stream = stream_fixture()
|
|
assert Streams.get_stream!(stream.id) == stream
|
|
end
|
|
|
|
test "create_stream/1 with valid data creates a stream" do
|
|
valid_attrs = %{date: ~U[2024-12-28 03:31:00Z], title: "some title", notes: "some notes"}
|
|
|
|
assert {:ok, %Stream{} = stream} = Streams.create_stream(valid_attrs)
|
|
assert stream.date == ~U[2024-12-28 03:31:00Z]
|
|
assert stream.title == "some title"
|
|
assert stream.notes == "some notes"
|
|
end
|
|
|
|
test "create_stream/1 with invalid data returns error changeset" do
|
|
assert {:error, %Ecto.Changeset{}} = Streams.create_stream(@invalid_attrs)
|
|
end
|
|
|
|
test "update_stream/2 with valid data updates the stream" do
|
|
stream = stream_fixture()
|
|
update_attrs = %{date: ~U[2024-12-29 03:31:00Z], title: "some updated title", notes: "some updated notes"}
|
|
|
|
assert {:ok, %Stream{} = stream} = Streams.update_stream(stream, update_attrs)
|
|
assert stream.date == ~U[2024-12-29 03:31:00Z]
|
|
assert stream.title == "some updated title"
|
|
assert stream.notes == "some updated notes"
|
|
end
|
|
|
|
test "update_stream/2 with invalid data returns error changeset" do
|
|
stream = stream_fixture()
|
|
assert {:error, %Ecto.Changeset{}} = Streams.update_stream(stream, @invalid_attrs)
|
|
assert stream == Streams.get_stream!(stream.id)
|
|
end
|
|
|
|
test "delete_stream/1 deletes the stream" do
|
|
stream = stream_fixture()
|
|
assert {:ok, %Stream{}} = Streams.delete_stream(stream)
|
|
assert_raise Ecto.NoResultsError, fn -> Streams.get_stream!(stream.id) end
|
|
end
|
|
|
|
test "change_stream/1 returns a stream changeset" do
|
|
stream = stream_fixture()
|
|
assert %Ecto.Changeset{} = Streams.change_stream(stream)
|
|
end
|
|
end
|
|
|
|
describe "vods" do
|
|
alias Bright.Streams.Vod
|
|
|
|
import Bright.StreamsFixtures
|
|
|
|
@invalid_attrs %{s3_cdn_url: nil, s3_upload_id: nil, s3_key: nil, s3_bucket: nil, mux_asset_id: nil, mux_playback_id: nil, ipfs_cid: nil, torrent: nil}
|
|
|
|
test "list_vods/0 returns all vods" do
|
|
vod = vod_fixture()
|
|
assert Streams.list_vods() == [vod]
|
|
end
|
|
|
|
test "get_vod!/1 returns the vod with given id" do
|
|
vod = vod_fixture()
|
|
assert Streams.get_vod!(vod.id) == vod
|
|
end
|
|
|
|
test "create_vod/1 with valid data creates a vod" do
|
|
valid_attrs = %{s3_cdn_url: "some s3_cdn_url", s3_upload_id: "some s3_upload_id", s3_key: "some s3_key", s3_bucket: "some s3_bucket", mux_asset_id: "some mux_asset_id", mux_playback_id: "some mux_playback_id", ipfs_cid: "some ipfs_cid", torrent: "some torrent"}
|
|
|
|
assert {:ok, %Vod{} = vod} = Streams.create_vod(valid_attrs)
|
|
assert vod.s3_cdn_url == "some s3_cdn_url"
|
|
assert vod.s3_upload_id == "some s3_upload_id"
|
|
assert vod.s3_key == "some s3_key"
|
|
assert vod.s3_bucket == "some s3_bucket"
|
|
assert vod.mux_asset_id == "some mux_asset_id"
|
|
assert vod.mux_playback_id == "some mux_playback_id"
|
|
assert vod.ipfs_cid == "some ipfs_cid"
|
|
assert vod.torrent == "some torrent"
|
|
end
|
|
|
|
test "create_vod/1 with invalid data returns error changeset" do
|
|
assert {:error, %Ecto.Changeset{}} = Streams.create_vod(@invalid_attrs)
|
|
end
|
|
|
|
test "update_vod/2 with valid data updates the vod" do
|
|
vod = vod_fixture()
|
|
update_attrs = %{s3_cdn_url: "some updated s3_cdn_url", s3_upload_id: "some updated s3_upload_id", s3_key: "some updated s3_key", s3_bucket: "some updated s3_bucket", mux_asset_id: "some updated mux_asset_id", mux_playback_id: "some updated mux_playback_id", ipfs_cid: "some updated ipfs_cid", torrent: "some updated torrent"}
|
|
|
|
assert {:ok, %Vod{} = vod} = Streams.update_vod(vod, update_attrs)
|
|
assert vod.s3_cdn_url == "some updated s3_cdn_url"
|
|
assert vod.s3_upload_id == "some updated s3_upload_id"
|
|
assert vod.s3_key == "some updated s3_key"
|
|
assert vod.s3_bucket == "some updated s3_bucket"
|
|
assert vod.mux_asset_id == "some updated mux_asset_id"
|
|
assert vod.mux_playback_id == "some updated mux_playback_id"
|
|
assert vod.ipfs_cid == "some updated ipfs_cid"
|
|
assert vod.torrent == "some updated torrent"
|
|
end
|
|
|
|
test "update_vod/2 with invalid data returns error changeset" do
|
|
vod = vod_fixture()
|
|
assert {:error, %Ecto.Changeset{}} = Streams.update_vod(vod, @invalid_attrs)
|
|
assert vod == Streams.get_vod!(vod.id)
|
|
end
|
|
|
|
test "delete_vod/1 deletes the vod" do
|
|
vod = vod_fixture()
|
|
assert {:ok, %Vod{}} = Streams.delete_vod(vod)
|
|
assert_raise Ecto.NoResultsError, fn -> Streams.get_vod!(vod.id) end
|
|
end
|
|
|
|
test "change_vod/1 returns a vod changeset" do
|
|
vod = vod_fixture()
|
|
assert %Ecto.Changeset{} = Streams.change_vod(vod)
|
|
end
|
|
end
|
|
end
|