diff options
author | lain <lain@soykaf.club> | 2020-11-19 16:12:01 +0100 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-11-19 16:12:01 +0100 |
commit | a60242464e6a92bf6de46a1cf7877799de27a3ce (patch) | |
tree | a5378a7a50a4dc02eed18871501b1112dfc5ec37 /test | |
parent | 6f9b03384fe50ce063e8fee3103a69dff298107b (diff) | |
download | pleroma-a60242464e6a92bf6de46a1cf7877799de27a3ce.tar.gz |
Search: Add option to search with the websearch function
Diffstat (limited to 'test')
-rw-r--r-- | test/pleroma/activity/search_test.exs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/pleroma/activity/search_test.exs b/test/pleroma/activity/search_test.exs new file mode 100644 index 000000000..ba3257d64 --- /dev/null +++ b/test/pleroma/activity/search_test.exs @@ -0,0 +1,45 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/> +# SPDX-License-Identifier: AGPL-3.0-only + +defmodule Pleroma.Activity.SearchTest do + use Pleroma.DataCase + + import Pleroma.Factory + alias Pleroma.Web.CommonAPI + alias Pleroma.Activity.Search + + test "it finds something" do + user = insert(:user) + {:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"}) + + [result] = Search.search(nil, "wednesday") + + assert result.id == post.id + end + + test "using plainto_tsquery" do + clear_config([:instance, :search_function], :plain) + + user = insert(:user) + {:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"}) + {:ok, _post2} = CommonAPI.post(user, %{status: "it's wednesday my bros"}) + + # plainto doesn't understand complex queries + assert [result] = Search.search(nil, "wednesday -dudes") + + assert result.id == post.id + end + + test "using websearch_to_tsquery" do + clear_config([:instance, :search_function], :websearch) + + 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] = Search.search(nil, "wednesday -dudes") + + assert result.id == other_post.id + end +end |