@@ -11,6 +11,7 @@ import (
1111
1212 "code.gitea.io/gitea/models/db"
1313 "code.gitea.io/gitea/models/unittest"
14+ indexer_module "code.gitea.io/gitea/modules/indexer"
1415 "code.gitea.io/gitea/modules/indexer/code/bleve"
1516 "code.gitea.io/gitea/modules/indexer/code/elasticsearch"
1617 "code.gitea.io/gitea/modules/indexer/code/internal"
@@ -39,10 +40,11 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
3940 assert .NoError (t , setupRepositoryIndexes (t .Context (), indexer ))
4041
4142 keywords := []struct {
42- RepoIDs []int64
43- Keyword string
44- Langs int
45- Results []codeSearchResult
43+ RepoIDs []int64
44+ Keyword string
45+ Langs int
46+ SearchMode indexer_module.SearchModeType
47+ Results []codeSearchResult
4648 }{
4749 // Search for an exact match on the contents of a file
4850 // This scenario yields a single result (the file README.md on the repo '1')
@@ -183,17 +185,18 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
183185 },
184186 // Search for matches on the contents of files regardless of case.
185187 {
186- RepoIDs : nil ,
187- Keyword : "dESCRIPTION" ,
188- Langs : 1 ,
188+ RepoIDs : nil ,
189+ Keyword : "dESCRIPTION" ,
190+ Langs : 1 ,
191+ SearchMode : indexer_module .SearchModeFuzzy ,
189192 Results : []codeSearchResult {
190193 {
191194 Filename : "README.md" ,
192195 Content : "# repo1\n \n Description for repo1" ,
193196 },
194197 },
195198 },
196- // Search for an exact match on the filename within the repo '62' (case insenstive ).
199+ // Search for an exact match on the filename within the repo '62' (case-insensitive ).
197200 // This scenario yields a single result (the file avocado.md on the repo '62')
198201 {
199202 RepoIDs : []int64 {62 },
@@ -206,7 +209,7 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
206209 },
207210 },
208211 },
209- // Search for matches on the contents of files when the criteria is a expression.
212+ // Search for matches on the contents of files when the criteria are an expression.
210213 {
211214 RepoIDs : []int64 {62 },
212215 Keyword : "console.log" ,
@@ -218,7 +221,7 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
218221 },
219222 },
220223 },
221- // Search for matches on the contents of files when the criteria is part of a expression.
224+ // Search for matches on the contents of files when the criteria are parts of an expression.
222225 {
223226 RepoIDs : []int64 {62 },
224227 Keyword : "log" ,
@@ -235,16 +238,16 @@ func testIndexer(name string, t *testing.T, indexer internal.Indexer) {
235238 for _ , kw := range keywords {
236239 t .Run (kw .Keyword , func (t * testing.T ) {
237240 total , res , langs , err := indexer .Search (t .Context (), & internal.SearchOptions {
238- RepoIDs : kw .RepoIDs ,
239- Keyword : kw .Keyword ,
241+ RepoIDs : kw .RepoIDs ,
242+ Keyword : kw .Keyword ,
243+ SearchMode : kw .SearchMode ,
240244 Paginator : & db.ListOptions {
241245 Page : 1 ,
242246 PageSize : 10 ,
243247 },
244- IsKeywordFuzzy : true ,
245248 })
246- assert .NoError (t , err )
247- assert .Len (t , langs , kw .Langs )
249+ require .NoError (t , err )
250+ require .Len (t , langs , kw .Langs )
248251
249252 hits := make ([]codeSearchResult , 0 , len (res ))
250253
@@ -289,7 +292,7 @@ func TestBleveIndexAndSearch(t *testing.T) {
289292 _ , err := idx .Init (t .Context ())
290293 require .NoError (t , err )
291294
292- testIndexer ("beleve " , t , idx )
295+ testIndexer ("bleve " , t , idx )
293296}
294297
295298func TestESIndexAndSearch (t * testing.T ) {
0 commit comments