* [WIP] add settings sidebar entry and placeholder page * [WIP] added placeholder UI and logic for settings form * Added column and UI for apprise server * Add some tests * Added placeholder command runner for apprise * [WIP] Adding apprise package * Added apprise command runner * Hooked up apprise notification module * Ensured apprise was running in verbose mode * Updated wording of apprise notification * Added apprise to README
66 lines
1.4 KiB
Elixir
66 lines
1.4 KiB
Elixir
defmodule Pinchflat.Boot.PreJobStartupTasksTest do
|
|
use Pinchflat.DataCase
|
|
|
|
import Mox
|
|
import Pinchflat.JobFixtures
|
|
|
|
alias Pinchflat.Settings
|
|
alias Pinchflat.Boot.PreJobStartupTasks
|
|
|
|
setup do
|
|
stub(YtDlpRunnerMock, :version, fn -> {:ok, "1"} end)
|
|
stub(AppriseRunnerMock, :version, fn -> {:ok, "2"} end)
|
|
|
|
:ok
|
|
end
|
|
|
|
describe "reset_executing_jobs" do
|
|
test "resets executing jobs" do
|
|
job = job_fixture()
|
|
Repo.update_all(Oban.Job, set: [state: "executing"])
|
|
|
|
assert Repo.reload!(job).state == "executing"
|
|
|
|
PreJobStartupTasks.init(%{})
|
|
|
|
assert Repo.reload!(job).state == "retryable"
|
|
end
|
|
end
|
|
|
|
describe "create_blank_cookie_file" do
|
|
test "creates a blank cookie file" do
|
|
base_dir = Application.get_env(:pinchflat, :extras_directory)
|
|
filepath = Path.join(base_dir, "cookies.txt")
|
|
File.rm(filepath)
|
|
|
|
refute File.exists?(filepath)
|
|
|
|
PreJobStartupTasks.init(%{})
|
|
|
|
assert File.exists?(filepath)
|
|
end
|
|
end
|
|
|
|
describe "apply_default_settings" do
|
|
test "sets yt_dlp version" do
|
|
Settings.set(yt_dlp_version: nil)
|
|
|
|
refute Settings.get!(:yt_dlp_version)
|
|
|
|
PreJobStartupTasks.init(%{})
|
|
|
|
assert Settings.get!(:yt_dlp_version)
|
|
end
|
|
|
|
test "sets apprise version" do
|
|
Settings.set(apprise_version: nil)
|
|
|
|
refute Settings.get!(:apprise_version)
|
|
|
|
PreJobStartupTasks.init(%{})
|
|
|
|
assert Settings.get!(:apprise_version)
|
|
end
|
|
end
|
|
end
|