akkoma/test/pleroma/search/database_search_test.exs

31 lines
909 B
Elixir
Raw Normal View History

# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Search.DatabaseSearchTest do
alias Pleroma.Search.DatabaseSearch
2020-11-19 15:48:51 +00:00
alias Pleroma.Web.CommonAPI
import Pleroma.Factory
use Pleroma.DataCase, async: true
test "it finds something" do
user = insert(:user)
{:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
[result] = DatabaseSearch.search(nil, "wednesday")
assert result.id == post.id
end
test "using websearch_to_tsquery" do
user = insert(:user)
{:ok, _post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
{:ok, other_post} = CommonAPI.post(user, %{status: "it's wednesday my bros"})
assert [result] = DatabaseSearch.search(nil, "wednesday -dudes")
assert result.id == other_post.id
end
end