2020-09-22 06:55:40 -06:00
|
|
|
# Pleroma: A lightweight social networking server
|
2022-02-25 23:11:42 -07:00
|
|
|
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
|
2020-09-22 06:55:40 -06:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
defmodule Pleroma.User.QueryTest do
|
|
|
|
use Pleroma.DataCase, async: true
|
|
|
|
|
|
|
|
alias Pleroma.Repo
|
|
|
|
alias Pleroma.User
|
|
|
|
alias Pleroma.User.Query
|
|
|
|
alias Pleroma.Web.ActivityPub.InternalFetchActor
|
|
|
|
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
|
|
|
describe "internal users" do
|
|
|
|
test "it filters out internal users by default" do
|
|
|
|
%User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
|
|
|
|
|
|
|
|
assert [_user] = User |> Repo.all()
|
|
|
|
assert [] == %{} |> Query.build() |> Repo.all()
|
|
|
|
end
|
|
|
|
|
|
|
|
test "it filters out users without nickname by default" do
|
|
|
|
insert(:user, %{nickname: nil})
|
|
|
|
|
|
|
|
assert [_user] = User |> Repo.all()
|
|
|
|
assert [] == %{} |> Query.build() |> Repo.all()
|
|
|
|
end
|
|
|
|
|
|
|
|
test "it returns internal users when enabled" do
|
|
|
|
%User{nickname: "internal.fetch"} = InternalFetchActor.get_actor()
|
|
|
|
insert(:user, %{nickname: nil})
|
|
|
|
|
|
|
|
assert %{internal: true} |> Query.build() |> Repo.aggregate(:count) == 2
|
|
|
|
end
|
|
|
|
end
|
2021-11-26 13:33:27 -07:00
|
|
|
|
|
|
|
test "is_suggested param" do
|
|
|
|
_user1 = insert(:user, is_suggested: false)
|
|
|
|
user2 = insert(:user, is_suggested: true)
|
|
|
|
|
|
|
|
assert [^user2] =
|
|
|
|
%{is_suggested: true}
|
|
|
|
|> User.Query.build()
|
|
|
|
|> Repo.all()
|
|
|
|
end
|
2020-09-22 06:55:40 -06:00
|
|
|
end
|