Cancel refresh cover job if image is not available

This commit is contained in:
Claudio Ortolina
2026-04-03 12:43:10 +01:00
parent 0339f7f11b
commit 4bfe27e6c8
2 changed files with 21 additions and 2 deletions
@@ -24,6 +24,18 @@ defmodule MusicLibrary.Worker.RefreshCoverTest do
assert asset.format == "image/jpeg"
end
@tag :capture_log
test "cancels the job when cover is not available" do
record = record()
Req.Test.stub(MusicBrainz.API, fn conn ->
Plug.Conn.send_resp(conn, 404, "Not Found")
end)
assert {:cancel, :cover_not_available} =
perform_job(RefreshCover, %{"id" => record.id})
end
test "raises when record does not exist" do
assert_raise Ecto.NoResultsError, fn ->
perform_job(RefreshCover, %{"id" => Ecto.UUID.generate()})