mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-04 09:25:22 +02:00
[v11/forgejo] fix: skip empty tokens in SearchOptions.Tokens() (#8412)
backport of #8261 to v11 Co-authored-by: Danko Aleksejevs <danko@very.lv> Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8412 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org> Co-authored-by: Shiny Nematoda <snematoda@noreply.codeberg.org> Co-committed-by: Shiny Nematoda <snematoda@noreply.codeberg.org>
This commit is contained in:
parent
0dc2bed2dd
commit
86b6553f3a
5 changed files with 146 additions and 16 deletions
|
@ -88,6 +88,11 @@ func TestIndexer(t *testing.T, indexer internal.Indexer) {
|
|||
}
|
||||
}
|
||||
|
||||
func allResults(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||
assert.Len(t, result.Hits, len(data))
|
||||
assert.Equal(t, len(data), int(result.Total))
|
||||
}
|
||||
|
||||
var cases = []*testIndexerCase{
|
||||
{
|
||||
Name: "default",
|
||||
|
@ -97,6 +102,34 @@ var cases = []*testIndexerCase{
|
|||
assert.Equal(t, len(data), int(result.Total))
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "empty keyword",
|
||||
SearchOptions: &internal.SearchOptions{
|
||||
Keyword: "",
|
||||
},
|
||||
Expected: allResults,
|
||||
},
|
||||
{
|
||||
Name: "whitespace keyword",
|
||||
SearchOptions: &internal.SearchOptions{
|
||||
Keyword: " ",
|
||||
},
|
||||
Expected: allResults,
|
||||
},
|
||||
{
|
||||
Name: "dangling slash in keyword",
|
||||
SearchOptions: &internal.SearchOptions{
|
||||
Keyword: "\\",
|
||||
},
|
||||
Expected: allResults,
|
||||
},
|
||||
{
|
||||
Name: "dangling quote in keyword",
|
||||
SearchOptions: &internal.SearchOptions{
|
||||
Keyword: "\"",
|
||||
},
|
||||
Expected: allResults,
|
||||
},
|
||||
{
|
||||
Name: "empty",
|
||||
SearchOptions: &internal.SearchOptions{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue