-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for video download worker
- Loading branch information
1 parent
777ccb7
commit 95a766f
Showing
2 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
defmodule Pinchflat.Workers.VideoDownloadWorkerTest do | ||
use Pinchflat.DataCase | ||
|
||
import Mox | ||
import Pinchflat.MediaFixtures | ||
|
||
alias Pinchflat.Workers.VideoDownloadWorker | ||
|
||
setup :verify_on_exit! | ||
|
||
setup do | ||
media_item = | ||
Repo.preload( | ||
media_item_fixture(%{video_filepath: nil}), | ||
[:metadata, channel: :media_profile] | ||
) | ||
|
||
{:ok, %{media_item: media_item}} | ||
end | ||
|
||
describe "perform/1" do | ||
test "it saves attributes to the media_item", %{media_item: media_item} do | ||
expect(YtDlpRunnerMock, :run, fn _url, _opts, _ot -> | ||
{:ok, render_metadata(:media_metadata)} | ||
end) | ||
|
||
assert media_item.video_filepath == nil | ||
perform_job(VideoDownloadWorker, %{id: media_item.id}) | ||
assert Repo.reload(media_item).video_filepath != nil | ||
end | ||
|
||
test "it saves the metadata to the media_item", %{media_item: media_item} do | ||
expect(YtDlpRunnerMock, :run, fn _url, _opts, _ot -> | ||
{:ok, render_metadata(:media_metadata)} | ||
end) | ||
|
||
assert media_item.metadata == nil | ||
perform_job(VideoDownloadWorker, %{id: media_item.id}) | ||
assert Repo.reload(media_item).metadata != nil | ||
end | ||
end | ||
end |