forked from AkkomaGang/akkoma
Co-authored-by: Oneric <oneric@oneric.stub> Co-authored-by: Floatingghost <hannah@coffee-and-dreams.uk> Co-authored-by: floatingghost <hannah@coffee-and-dreams.uk> Co-authored-by: cevado <cevado@tutanota.com> Co-authored-by: TudbuT <tudbut@tudbut.de> Co-authored-by: Haelwenn (lanodan) Monnier <contact@hacktivis.me> Reviewed-on: #5 Reviewed-on: #6
30 lines
909 B
Elixir
30 lines
909 B
Elixir
# 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
|
|
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
|