Misc refactors 2024-03-14 (#89)
* Adds method to improve cleanup of empty directories * resolved bug where source metadata worker could call itself in an infinite loop * Refactored file deletion for media items * Removed useless filesystem data worker * Updated task listing fns to take a record directly * Refactored the way I call workers * Improved some tests
This commit is contained in:
@@ -9,6 +9,23 @@ defmodule Pinchflat.FastIndexing.FastIndexingWorkerTest do
|
||||
|
||||
setup :verify_on_exit!
|
||||
|
||||
describe "kickoff_with_task/2" do
|
||||
test "starts the worker" do
|
||||
source = source_fixture(fast_index: true)
|
||||
|
||||
assert [] = all_enqueued(worker: FastIndexingWorker)
|
||||
assert {:ok, _} = FastIndexingWorker.kickoff_with_task(source)
|
||||
assert [_] = all_enqueued(worker: FastIndexingWorker)
|
||||
end
|
||||
|
||||
test "attaches a task" do
|
||||
source = source_fixture(fast_index: true)
|
||||
|
||||
assert {:ok, task} = FastIndexingWorker.kickoff_with_task(source)
|
||||
assert task.source_id == source.id
|
||||
end
|
||||
end
|
||||
|
||||
describe "perform/1" do
|
||||
test "calls out to Youtube RSS if enabled" do
|
||||
expect(HTTPClientMock, :get, fn _url -> {:ok, ""} end)
|
||||
@@ -29,6 +46,16 @@ defmodule Pinchflat.FastIndexing.FastIndexingWorkerTest do
|
||||
)
|
||||
end
|
||||
|
||||
test "does not reschedule if that would create a duplicate job" do
|
||||
stub(HTTPClientMock, :get, fn _url -> {:ok, ""} end)
|
||||
source = source_fixture(fast_index: true)
|
||||
|
||||
perform_job(FastIndexingWorker, %{"id" => source.id})
|
||||
perform_job(FastIndexingWorker, %{"id" => source.id})
|
||||
|
||||
assert [_] = all_enqueued(worker: FastIndexingWorker)
|
||||
end
|
||||
|
||||
test "does not call out to Youtube RSS if disabled" do
|
||||
expect(HTTPClientMock, :get, 0, fn _url -> {:ok, ""} end)
|
||||
source = source_fixture(fast_index: false)
|
||||
|
||||
Reference in New Issue
Block a user