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