mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-23 19:11:58 +01:00
test: add for issue indexer sort by score
This commit is contained in:
parent
a265574821
commit
b6e6a2c36e
1 changed files with 20 additions and 0 deletions
|
@ -126,6 +126,7 @@ var cases = []*testIndexerCase{
|
||||||
},
|
},
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Keyword: "hello",
|
Keyword: "hello",
|
||||||
|
SortBy: internal.SortByCreatedDesc,
|
||||||
},
|
},
|
||||||
ExpectedIDs: []int64{1002, 1001, 1000},
|
ExpectedIDs: []int64{1002, 1001, 1000},
|
||||||
ExpectedTotal: 3,
|
ExpectedTotal: 3,
|
||||||
|
@ -139,6 +140,7 @@ var cases = []*testIndexerCase{
|
||||||
},
|
},
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Keyword: "hello world",
|
Keyword: "hello world",
|
||||||
|
SortBy: internal.SortByCreatedDesc,
|
||||||
IsFuzzyKeyword: true,
|
IsFuzzyKeyword: true,
|
||||||
},
|
},
|
||||||
ExpectedIDs: []int64{1002, 1001, 1000},
|
ExpectedIDs: []int64{1002, 1001, 1000},
|
||||||
|
@ -157,6 +159,7 @@ var cases = []*testIndexerCase{
|
||||||
},
|
},
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Keyword: "hello",
|
Keyword: "hello",
|
||||||
|
SortBy: internal.SortByCreatedDesc,
|
||||||
RepoIDs: []int64{1, 4},
|
RepoIDs: []int64{1, 4},
|
||||||
},
|
},
|
||||||
ExpectedIDs: []int64{1006, 1002, 1001},
|
ExpectedIDs: []int64{1006, 1002, 1001},
|
||||||
|
@ -175,6 +178,7 @@ var cases = []*testIndexerCase{
|
||||||
},
|
},
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
Keyword: "hello",
|
Keyword: "hello",
|
||||||
|
SortBy: internal.SortByCreatedDesc,
|
||||||
RepoIDs: []int64{1, 4},
|
RepoIDs: []int64{1, 4},
|
||||||
AllPublic: true,
|
AllPublic: true,
|
||||||
},
|
},
|
||||||
|
@ -597,6 +601,22 @@ var cases = []*testIndexerCase{
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "SortByScore",
|
||||||
|
SearchOptions: &internal.SearchOptions{
|
||||||
|
Paginator: &db.ListOptionsAll,
|
||||||
|
SortBy: internal.SortByScore,
|
||||||
|
},
|
||||||
|
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
|
||||||
|
assert.Equal(t, len(data), len(result.Hits))
|
||||||
|
assert.Equal(t, len(data), int(result.Total))
|
||||||
|
for i, v := range result.Hits {
|
||||||
|
if i < len(result.Hits)-1 {
|
||||||
|
assert.GreaterOrEqual(t, v.Score, result.Hits[i+1].Score)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "SortByCreatedAsc",
|
Name: "SortByCreatedAsc",
|
||||||
SearchOptions: &internal.SearchOptions{
|
SearchOptions: &internal.SearchOptions{
|
||||||
|
|
Loading…
Reference in a new issue