Move code indexer related code to a new package (#9191)

* move code indexer related code to a new package

* fix lint

* fix tests

* fix fmt

* GetMaxID support interface parameter
This commit is contained in:
2019-12-09 03:15:35 +08:00
committed by techknowlogick
parent baf089e5b9
commit be06dee04c
9 changed files with 434 additions and 379 deletions

View File

@ -10,6 +10,7 @@ import (
"time"
"code.gitea.io/gitea/models"
code_indexer "code.gitea.io/gitea/modules/indexer/code"
"code.gitea.io/gitea/modules/setting"
"github.com/PuerkitoBio/goquery"
@ -34,7 +35,7 @@ func TestSearchRepo(t *testing.T) {
repo, err := models.GetRepositoryByOwnerAndName("user2", "repo1")
assert.NoError(t, err)
executeIndexer(t, repo, models.UpdateRepoIndexer)
executeIndexer(t, repo, code_indexer.UpdateRepoIndexer)
testSearch(t, "/user2/repo1/search?q=Description&page=1", []string{"README.md"})
@ -44,8 +45,8 @@ func TestSearchRepo(t *testing.T) {
repo, err = models.GetRepositoryByOwnerAndName("user2", "glob")
assert.NoError(t, err)
executeIndexer(t, repo, models.DeleteRepoFromIndexer)
executeIndexer(t, repo, models.UpdateRepoIndexer)
executeIndexer(t, repo, code_indexer.DeleteRepoFromIndexer)
executeIndexer(t, repo, code_indexer.UpdateRepoIndexer)
testSearch(t, "/user2/glob/search?q=loren&page=1", []string{"a.txt"})
testSearch(t, "/user2/glob/search?q=file3&page=1", []string{"x/b.txt"})