1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.MediaProxy.Invalidation.HttpTest do
7 alias Pleroma.Web.MediaProxy.Invalidation
9 import ExUnit.CaptureLog
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"