diff options
author | Lauris BH <lauris@nix.lv> | 2020-02-20 21:53:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-20 16:53:55 -0300 |
commit | 3c45cf8494fcd29e1a99b0ee6f253808eb607053 (patch) | |
tree | cd0e6347bcd2bfc42c18408169a8757ca1dda920 /modules/indexer/code/bleve_test.go | |
parent | efbd7ca39bde69ff84d4b309bee99edfe2977521 (diff) | |
download | gitea-3c45cf8494fcd29e1a99b0ee6f253808eb607053.tar.gz gitea-3c45cf8494fcd29e1a99b0ee6f253808eb607053.zip |
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
Diffstat (limited to 'modules/indexer/code/bleve_test.go')
-rw-r--r-- | modules/indexer/code/bleve_test.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/indexer/code/bleve_test.go b/modules/indexer/code/bleve_test.go index 695dceb259..89cfceea2d 100644 --- a/modules/indexer/code/bleve_test.go +++ b/modules/indexer/code/bleve_test.go @@ -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) |