Update eblurhash to a non-bugged version (#34)
[akkoma] / test / pleroma / upload / filter / analyze_metadata_test.exs
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4
5 defmodule Pleroma.Upload.Filter.AnalyzeMetadataTest do
6 use Pleroma.DataCase, async: true
7 alias Pleroma.Upload.Filter.AnalyzeMetadata
8
9 test "adds the dimensions and blurhash for images" do
10 upload = %Pleroma.Upload{
11 name: "an… image.jpg",
12 content_type: "image/jpeg",
13 path: Path.absname("test/fixtures/image.jpg"),
14 tempfile: Path.absname("test/fixtures/image.jpg")
15 }
16
17 {:ok, :filtered, meta} = AnalyzeMetadata.filter(upload)
18
19 assert %{width: 1024, height: 768} = meta
20 assert meta.blurhash
21 # Blurhashes should be a valid base83 string
22 assert meta.blurhash =~ ~r/^[A-Za-z0-9#$%*\+,-\.:;=\?@\[\]\^_{|}~]{6,}$/
23 end
24
25 test "adds the dimensions for videos" do
26 upload = %Pleroma.Upload{
27 name: "coolvideo.mp4",
28 content_type: "video/mp4",
29 path: Path.absname("test/fixtures/video.mp4"),
30 tempfile: Path.absname("test/fixtures/video.mp4")
31 }
32
33 assert {:ok, :filtered, %{width: 480, height: 480}} = AnalyzeMetadata.filter(upload)
34 end
35 end