mix tasks consistency
[akkoma] / test / upload / filter_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.Upload.FilterTest do
6 use Pleroma.DataCase
7
8 alias Pleroma.Config
9 alias Pleroma.Upload.Filter
10
11 setup do: clear_config([Pleroma.Upload.Filter.AnonymizeFilename, :text])
12
13 test "applies filters" do
14 Config.put([Pleroma.Upload.Filter.AnonymizeFilename, :text], "custom-file.png")
15
16 File.cp!(
17 "test/fixtures/image.jpg",
18 "test/fixtures/image_tmp.jpg"
19 )
20
21 upload = %Pleroma.Upload{
22 name: "an… image.jpg",
23 content_type: "image/jpg",
24 path: Path.absname("test/fixtures/image_tmp.jpg"),
25 tempfile: Path.absname("test/fixtures/image_tmp.jpg")
26 }
27
28 assert Filter.filter([], upload) == {:ok, upload}
29
30 assert {:ok, upload} = Filter.filter([Pleroma.Upload.Filter.AnonymizeFilename], upload)
31 assert upload.name == "custom-file.png"
32 end
33 end