summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-02-25 00:16:20 +0800
committertechknowlogick <matti@mdranta.net>2019-02-24 11:16:20 -0500
commit15ecc08475c49926b9d5f6fb4182578683f75d63 (patch)
tree94064c7701146619b05dd614b42dde68d8c370c5 /modules
parent05143768d0948d3f5e24aa5b87b68ee2ae9a7e6f (diff)
downloadgitea-15ecc08475c49926b9d5f6fb4182578683f75d63.tar.gz
gitea-15ecc08475c49926b9d5f6fb4182578683f75d63.zip
fix bug when set indexer as db and add tests (#6173)
Diffstat (limited to 'modules')
-rw-r--r--modules/indexer/issues/bleve_test.go2
-rw-r--r--modules/indexer/issues/indexer.go1
-rw-r--r--modules/indexer/issues/indexer_test.go30
3 files changed, 30 insertions, 3 deletions
diff --git a/modules/indexer/issues/bleve_test.go b/modules/indexer/issues/bleve_test.go
index 720266e3b5..8ec274566f 100644
--- a/modules/indexer/issues/bleve_test.go
+++ b/modules/indexer/issues/bleve_test.go
@@ -11,7 +11,7 @@ import (
"github.com/stretchr/testify/assert"
)
-func TestIndexAndSearch(t *testing.T) {
+func TestBleveIndexAndSearch(t *testing.T) {
dir := "./bleve.index"
indexer := NewBleveIndexer(dir)
defer os.RemoveAll(dir)
diff --git a/modules/indexer/issues/indexer.go b/modules/indexer/issues/indexer.go
index c5d6d05a60..4d7e64adc7 100644
--- a/modules/indexer/issues/indexer.go
+++ b/modules/indexer/issues/indexer.go
@@ -72,6 +72,7 @@ func InitIssueIndexer(syncReindex bool) error {
}
if dummyQueue {
+ issueIndexerUpdateQueue = &DummyQueue{}
return nil
}
diff --git a/modules/indexer/issues/indexer_test.go b/modules/indexer/issues/indexer_test.go
index 66087e3e6b..6ecd9fe779 100644
--- a/modules/indexer/issues/indexer_test.go
+++ b/modules/indexer/issues/indexer_test.go
@@ -26,16 +26,42 @@ func TestMain(m *testing.M) {
models.MainTest(m, filepath.Join("..", "..", ".."))
}
-func TestSearchIssues(t *testing.T) {
+func TestBleveSearchIssues(t *testing.T) {
assert.NoError(t, models.PrepareTestDatabase())
os.RemoveAll(setting.Indexer.IssueIndexerQueueDir)
os.RemoveAll(setting.Indexer.IssuePath)
+ setting.Indexer.IssueType = "bleve"
if err := InitIssueIndexer(true); err != nil {
fatalTestError("Error InitIssueIndexer: %v\n", err)
}
- time.Sleep(10 * time.Second)
+ time.Sleep(5 * time.Second)
+
+ ids, err := SearchIssuesByKeyword(1, "issue2")
+ assert.NoError(t, err)
+ assert.EqualValues(t, []int64{2}, ids)
+
+ ids, err = SearchIssuesByKeyword(1, "first")
+ assert.NoError(t, err)
+ assert.EqualValues(t, []int64{1}, ids)
+
+ ids, err = SearchIssuesByKeyword(1, "for")
+ assert.NoError(t, err)
+ assert.EqualValues(t, []int64{1, 2, 3, 5}, ids)
+
+ ids, err = SearchIssuesByKeyword(1, "good")
+ assert.NoError(t, err)
+ assert.EqualValues(t, []int64{1}, ids)
+}
+
+func TestDBSearchIssues(t *testing.T) {
+ assert.NoError(t, models.PrepareTestDatabase())
+
+ setting.Indexer.IssueType = "db"
+ if err := InitIssueIndexer(true); err != nil {
+ fatalTestError("Error InitIssueIndexer: %v\n", err)
+ }
ids, err := SearchIssuesByKeyword(1, "issue2")
assert.NoError(t, err)