remove `unread_conversation_count` from User
[akkoma] / test / pleroma / web / media_proxy / invalidation / http_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Web.MediaProxy.Invalidation.HttpTest do
6 use ExUnit.Case
7 alias Pleroma.Web.MediaProxy.Invalidation
8
9 import ExUnit.CaptureLog
10 import Tesla.Mock
11
12 setup do
13 on_exit(fn -> Cachex.clear(:banned_urls_cache) end)
14 end
15
16 test "logs hasn't error message when request is valid" do
17 mock(fn
18 %{method: :purge, url: "http://example.com/media/example.jpg"} ->
19 %Tesla.Env{status: 200}
20 end)
21
22 refute capture_log(fn ->
23 assert Invalidation.Http.purge(
24 ["http://example.com/media/example.jpg"],
25 []
26 ) == {:ok, ["http://example.com/media/example.jpg"]}
27 end) =~ "Error while cache purge"
28 end
29
30 test "it write error message in logs when request invalid" do
31 mock(fn
32 %{method: :purge, url: "http://example.com/media/example1.jpg"} ->
33 %Tesla.Env{status: 404}
34 end)
35
36 assert capture_log(fn ->
37 assert Invalidation.Http.purge(
38 ["http://example.com/media/example1.jpg"],
39 []
40 ) == {:ok, ["http://example.com/media/example1.jpg"]}
41 end) =~ "Error while cache purge: url - http://example.com/media/example1.jpg"
42 end
43 end