Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33095880
database_search_test.exs
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
database_search_test.exs
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Search.DatabaseSearchTest
do
alias
Pleroma.Search.DatabaseSearch
,
as
:
Search
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
]
=
Search
.
search
(
nil
,
"wednesday"
)
assert
result
.
id
==
post
.
id
end
test
"it finds local-only posts for authenticated users"
do
user
=
insert
(
:user
)
reader
=
insert
(
:user
)
{
:ok
,
post
}
=
CommonAPI
.
post
(
user
,
%{
status
:
"it's wednesday my dudes"
,
visibility
:
"local"
})
[
result
]
=
Search
.
search
(
reader
,
"wednesday"
)
assert
result
.
id
==
post
.
id
end
test
"it does not find local-only posts for anonymous users"
do
user
=
insert
(
:user
)
{
:ok
,
_post
}
=
CommonAPI
.
post
(
user
,
%{
status
:
"it's wednesday my dudes"
,
visibility
:
"local"
})
assert
[]
=
Search
.
search
(
nil
,
"wednesday"
)
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
]
=
Search
.
search
(
nil
,
"wednesday -dudes"
)
assert
result
.
id
==
other_post
.
id
end
end
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Jan 20, 9:57 AM (1 d, 8 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
960154
Default Alt Text
database_search_test.exs (1 KB)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment