added tests

This commit is contained in:
Kieran Eglin 2024-11-08 14:35:35 -08:00
parent e77e530f65
commit 8922bd84a2
No known key found for this signature in database
GPG key ID: 193984967FCF432D
2 changed files with 13 additions and 1 deletions

View file

@ -98,7 +98,6 @@ defmodule Pinchflat.Boot.PreJobStartupTasks do
Settings.set(apprise_version: apprise_version) Settings.set(apprise_version: apprise_version)
end end
# TODO: test
defp run_app_init_script do defp run_app_init_script do
runner = Application.get_env(:pinchflat, :user_script_runner, UserScriptRunner) runner = Application.get_env(:pinchflat, :user_script_runner, UserScriptRunner)

View file

@ -9,6 +9,7 @@ defmodule Pinchflat.Boot.PreJobStartupTasksTest do
setup do setup do
stub(YtDlpRunnerMock, :version, fn -> {:ok, "1"} end) stub(YtDlpRunnerMock, :version, fn -> {:ok, "1"} end)
stub(AppriseRunnerMock, :version, fn -> {:ok, "2"} end) stub(AppriseRunnerMock, :version, fn -> {:ok, "2"} end)
stub(UserScriptRunnerMock, :run, fn _event_type, _data -> {:ok, "3", 0} end)
:ok :ok
end end
@ -112,4 +113,16 @@ defmodule Pinchflat.Boot.PreJobStartupTasksTest do
assert Settings.get!(:apprise_version) assert Settings.get!(:apprise_version)
end end
end end
describe "run_app_init_script" do
test "calls the app_init user script runner" do
expect(UserScriptRunnerMock, :run, fn :app_init, data ->
assert data == %{}
{:ok, "", 0}
end)
PreJobStartupTasks.init(%{})
end
end
end end