logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

query_test.exs (1113B)


  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. defmodule Pleroma.User.QueryTest do
  5. use Pleroma.DataCase, async: true
  6. alias Pleroma.Repo
  7. alias Pleroma.User
  8. alias Pleroma.User.Query
  9. alias Pleroma.Web.ActivityPub.InternalFetchActor
  10. import Pleroma.Factory
  11. describe "internal users" do
  12. test "it filters out internal users by default" do
  13. %User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
  14. assert [_user] = User |> Repo.all()
  15. assert [] == %{} |> Query.build() |> Repo.all()
  16. end
  17. test "it filters out users without nickname by default" do
  18. insert(:user, %{nickname: nil})
  19. assert [_user] = User |> Repo.all()
  20. assert [] == %{} |> Query.build() |> Repo.all()
  21. end
  22. test "it returns internal users when enabled" do
  23. %User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
  24. insert(:user, %{nickname: nil})
  25. assert %{internal: true} |> Query.build() |> Repo.aggregate(:count) == 2
  26. end
  27. end
  28. end