Uploading an avatar media exceeding max size returns a 413
[akkoma] / test / pleroma / user / query_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.User.QueryTest do
6 use Pleroma.DataCase, async: true
7
8 alias Pleroma.Repo
9 alias Pleroma.User
10 alias Pleroma.User.Query
11 alias Pleroma.Web.ActivityPub.InternalFetchActor
12
13 import Pleroma.Factory
14
15 describe "internal users" do
16 test "it filters out internal users by default" do
17 %User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
18
19 assert [_user] = User |> Repo.all()
20 assert [] == %{} |> Query.build() |> Repo.all()
21 end
22
23 test "it filters out users without nickname by default" do
24 insert(:user, %{nickname: nil})
25
26 assert [_user] = User |> Repo.all()
27 assert [] == %{} |> Query.build() |> Repo.all()
28 end
29
30 test "it returns internal users when enabled" do
31 %User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
32 insert(:user, %{nickname: nil})
33
34 assert %{internal: true} |> Query.build() |> Repo.aggregate(:count) == 2
35 end
36 end
37
38 test "is_suggested param" do
39 _user1 = insert(:user, is_suggested: false)
40 user2 = insert(:user, is_suggested: true)
41
42 assert [^user2] =
43 %{is_suggested: true}
44 |> User.Query.build()
45 |> Repo.all()
46 end
47 end