1 defmodule Pleroma.Web.MediaProxy.Invalidation.HttpTest do
3 alias Pleroma.Web.MediaProxy.Invalidation
5 import ExUnit.CaptureLog
9 on_exit(fn -> Cachex.clear(:deleted_urls_cache) end)
13 test "logs hasn't error message when request is valid" do
15 %{method: :purge, url: "http://example.com/media/example.jpg"} ->
16 %Tesla.Env{status: 200}
19 refute capture_log(fn ->
20 assert Invalidation.Http.purge(
21 ["http://example.com/media/example.jpg"],
23 ) == {:ok, ["http://example.com/media/example.jpg"]}
24 end) =~ "Error while cache purge"
27 test "it write error message in logs when request invalid" do
29 %{method: :purge, url: "http://example.com/media/example1.jpg"} ->
30 %Tesla.Env{status: 404}
33 assert capture_log(fn ->
34 assert Invalidation.Http.purge(
35 ["http://example.com/media/example1.jpg"],
37 ) == {:ok, ["http://example.com/media/example1.jpg"]}
38 end) =~ "Error while cache purge: url - http://example.com/media/example1.jpg"