2020-11-19 08:12:01 -07:00
|
|
|
# Pleroma: A lightweight social networking server
|
2021-01-12 23:49:20 -07:00
|
|
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
2020-11-19 08:12:01 -07:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2021-11-17 12:29:49 -07:00
|
|
|
defmodule Pleroma.Search.DatabaseSearchTest do
|
|
|
|
alias Pleroma.Search.DatabaseSearch
|
2020-11-19 08:48:51 -07:00
|
|
|
alias Pleroma.Web.CommonAPI
|
|
|
|
import Pleroma.Factory
|
|
|
|
|
2020-12-21 04:21:40 -07:00
|
|
|
use Pleroma.DataCase, async: true
|
2020-11-19 08:12:01 -07:00
|
|
|
|
|
|
|
test "it finds something" do
|
|
|
|
user = insert(:user)
|
|
|
|
{:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
|
|
|
|
|
2021-11-17 12:29:49 -07:00
|
|
|
[result] = DatabaseSearch.search(nil, "wednesday")
|
2020-11-19 08:12:01 -07:00
|
|
|
|
|
|
|
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"})
|
|
|
|
|
2021-11-17 12:29:49 -07:00
|
|
|
assert [result] = DatabaseSearch.search(nil, "wednesday -dudes")
|
2020-11-19 08:12:01 -07:00
|
|
|
|
|
|
|
assert result.id == other_post.id
|
|
|
|
end
|
|
|
|
end
|