mirror of
https://github.com/go-gitea/gitea
synced 2025-07-05 18:17:19 +00:00
Add detected file language to code search (#10256)
Move langauge detection to separate module to be more reusable Add option to disable vendored file exclusion from file search Allways show all language stats for search
This commit is contained in:
@ -49,27 +49,34 @@ func TestIndexAndSearch(t *testing.T) {
|
||||
keywords = []struct {
|
||||
Keyword string
|
||||
IDs []int64
|
||||
Langs int
|
||||
}{
|
||||
{
|
||||
Keyword: "Description",
|
||||
IDs: []int64{1},
|
||||
Langs: 1,
|
||||
},
|
||||
{
|
||||
Keyword: "repo1",
|
||||
IDs: []int64{1},
|
||||
Langs: 1,
|
||||
},
|
||||
{
|
||||
Keyword: "non-exist",
|
||||
IDs: []int64{},
|
||||
Langs: 0,
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
for _, kw := range keywords {
|
||||
total, res, err := idx.Search(nil, kw.Keyword, 1, 10)
|
||||
total, res, langs, err := idx.Search(nil, "", kw.Keyword, 1, 10)
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, len(kw.IDs), total)
|
||||
|
||||
assert.NotNil(t, langs)
|
||||
assert.Len(t, langs, kw.Langs)
|
||||
|
||||
var ids = make([]int64, 0, len(res))
|
||||
for _, hit := range res {
|
||||
ids = append(ids, hit.RepoID)
|
||||
|
Reference in New Issue
Block a user