pinchflat/test/pinchflat/yt_dlp/update_worker_test.exs
Kieran 6ead29182d
[Enhancement] Auto-update yt-dlp (#589)
* Added a command for updating yt-dlp

* Added a yt-dlp update worker to run daily

* Added a new file that runs post-boot when the app is ready to serve requests; put yt-dlp updater in there

* Updated config to expose the current env globally; updated startup tasks to not run in test env

* Removes unneeded test code
2025-01-27 11:33:38 -08:00

24 lines
681 B
Elixir

defmodule Pinchflat.YtDlp.UpdateWorkerTest do
use Pinchflat.DataCase
alias Pinchflat.Settings
alias Pinchflat.YtDlp.UpdateWorker
describe "perform/1" do
test "calls the yt-dlp runner to update yt-dlp" do
expect(YtDlpRunnerMock, :update, fn -> {:ok, ""} end)
expect(YtDlpRunnerMock, :version, fn -> {:ok, ""} end)
perform_job(UpdateWorker, %{})
end
test "saves the new version to the database" do
expect(YtDlpRunnerMock, :update, fn -> {:ok, ""} end)
expect(YtDlpRunnerMock, :version, fn -> {:ok, "1.2.3"} end)
perform_job(UpdateWorker, %{})
assert {:ok, "1.2.3"} = Settings.get(:yt_dlp_version)
end
end
end