|
|
@ -26,16 +26,42 @@ func TestMain(m *testing.M) { |
|
|
|
models.MainTest(m, filepath.Join("..", "..", "..")) |
|
|
|
models.MainTest(m, filepath.Join("..", "..", "..")) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func TestSearchIssues(t *testing.T) { |
|
|
|
func TestBleveSearchIssues(t *testing.T) { |
|
|
|
assert.NoError(t, models.PrepareTestDatabase()) |
|
|
|
assert.NoError(t, models.PrepareTestDatabase()) |
|
|
|
|
|
|
|
|
|
|
|
os.RemoveAll(setting.Indexer.IssueIndexerQueueDir) |
|
|
|
os.RemoveAll(setting.Indexer.IssueIndexerQueueDir) |
|
|
|
os.RemoveAll(setting.Indexer.IssuePath) |
|
|
|
os.RemoveAll(setting.Indexer.IssuePath) |
|
|
|
|
|
|
|
setting.Indexer.IssueType = "bleve" |
|
|
|
if err := InitIssueIndexer(true); err != nil { |
|
|
|
if err := InitIssueIndexer(true); err != nil { |
|
|
|
fatalTestError("Error InitIssueIndexer: %v\n", err) |
|
|
|
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") |
|
|
|
ids, err := SearchIssuesByKeyword(1, "issue2") |
|
|
|
assert.NoError(t, err) |
|
|
|
assert.NoError(t, err) |
|
|
|