diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-10-26 23:10:54 -0700 |
---|---|---|
committer | Lauris BH <lauris@nix.lv> | 2017-10-27 09:10:54 +0300 |
commit | 5866eb23217de4d29b181e30c26cee28ebc6aedc (patch) | |
tree | f8f67462544c709e8dd6988ca4d55a22cfc3a22c /integrations | |
parent | 762f1d7237de5727815ebda9593f7f9a20a5a077 (diff) | |
download | gitea-5866eb23217de4d29b181e30c26cee28ebc6aedc.tar.gz gitea-5866eb23217de4d29b181e30c26cee28ebc6aedc.zip |
Code/repo search (#2582)
Indexed search of repository contents (for default branch only)
Diffstat (limited to 'integrations')
-rw-r--r-- | integrations/integration_test.go | 4 | ||||
-rw-r--r-- | integrations/mysql.ini.tmpl | 2 | ||||
-rw-r--r-- | integrations/pgsql.ini.tmpl | 2 | ||||
-rw-r--r-- | integrations/repo_search_test.go | 35 | ||||
-rw-r--r-- | integrations/sqlite.ini | 2 |
5 files changed, 45 insertions, 0 deletions
diff --git a/integrations/integration_test.go b/integrations/integration_test.go index bfe5cef93d..4573a9cb13 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -63,6 +63,10 @@ func TestMain(m *testing.M) { fmt.Printf("os.RemoveAll: %v\n", err) os.Exit(1) } + if err = os.RemoveAll(setting.Indexer.RepoPath); err != nil { + fmt.Printf("Unable to remove repo indexer: %v\n", err) + os.Exit(1) + } os.Exit(exitCode) } diff --git a/integrations/mysql.ini.tmpl b/integrations/mysql.ini.tmpl index 0f154ac684..5dd573cb17 100644 --- a/integrations/mysql.ini.tmpl +++ b/integrations/mysql.ini.tmpl @@ -12,6 +12,8 @@ PATH = data/gitea.db [indexer] ISSUE_INDEXER_PATH = integrations/indexers-mysql/issues.bleve +REPO_INDEXER_ENABLED = true +REPO_INDEXER_PATH = integrations/indexers-mysql/repos.bleve [repository] ROOT = integrations/gitea-integration-mysql/gitea-repositories diff --git a/integrations/pgsql.ini.tmpl b/integrations/pgsql.ini.tmpl index 301af53b86..d3f741e303 100644 --- a/integrations/pgsql.ini.tmpl +++ b/integrations/pgsql.ini.tmpl @@ -12,6 +12,8 @@ PATH = data/gitea.db [indexer] ISSUE_INDEXER_PATH = integrations/indexers-pgsql/issues.bleve +REPO_INDEXER_ENABLED = true +REPO_INDEXER_PATH = integrations/indexers-pgsql/repos.bleve [repository] ROOT = integrations/gitea-integration-pgsql/gitea-repositories diff --git a/integrations/repo_search_test.go b/integrations/repo_search_test.go new file mode 100644 index 0000000000..d7d07ca8d0 --- /dev/null +++ b/integrations/repo_search_test.go @@ -0,0 +1,35 @@ +// Copyright 2017 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package integrations + +import ( + "net/http" + "testing" + + "github.com/PuerkitoBio/goquery" + "github.com/stretchr/testify/assert" +) + +func resultFilenames(t testing.TB, doc *HTMLDoc) []string { + resultsSelection := doc.doc.Find(".repository.search") + assert.EqualValues(t, 1, resultsSelection.Length(), + "Invalid template (repo search template has changed?)") + filenameSelections := resultsSelection.Find(".repo-search-result").Find(".header").Find("span.file") + result := make([]string, filenameSelections.Length()) + filenameSelections.Each(func(i int, selection *goquery.Selection) { + result[i] = selection.Text() + }) + return result +} + +func TestSearchRepo(t *testing.T) { + prepareTestEnv(t) + + req := NewRequestf(t, "GET", "/user2/repo1/search?q=Description&page=1") + resp := MakeRequest(t, req, http.StatusOK) + + filenames := resultFilenames(t, NewHTMLParser(t, resp.Body)) + assert.EqualValues(t, []string{"README.md"}, filenames) +} diff --git a/integrations/sqlite.ini b/integrations/sqlite.ini index 9dd38cc6e3..8a3a5356b4 100644 --- a/integrations/sqlite.ini +++ b/integrations/sqlite.ini @@ -7,6 +7,8 @@ PATH = :memory: [indexer] ISSUE_INDEXER_PATH = integrations/indexers-sqlite/issues.bleve +REPO_INDEXER_ENABLED = true +REPO_INDEXER_PATH = integrations/indexers-sqlite/repos.bleve [repository] ROOT = integrations/gitea-integration-sqlite/gitea-repositories |