1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.User.QueryTest do
6 use Pleroma.DataCase, async: true
10 alias Pleroma.User.Query
11 alias Pleroma.Web.ActivityPub.InternalFetchActor
13 import Pleroma.Factory
15 describe "internal users" do
16 test "it filters out internal users by default" do
17 %User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
19 assert [_user] = User |> Repo.all()
20 assert [] == %{} |> Query.build() |> Repo.all()
23 test "it filters out users without nickname by default" do
24 insert(:user, %{nickname: nil})
26 assert [_user] = User |> Repo.all()
27 assert [] == %{} |> Query.build() |> Repo.all()
30 test "it returns internal users when enabled" do
31 %User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
32 insert(:user, %{nickname: nil})
34 assert %{internal: true} |> Query.build() |> Repo.aggregate(:count) == 2