diff options
Diffstat (limited to 'modules/indexer/issues/indexer_test.go')
-rw-r--r-- | modules/indexer/issues/indexer_test.go | 88 |
1 files changed, 64 insertions, 24 deletions
diff --git a/modules/indexer/issues/indexer_test.go b/modules/indexer/issues/indexer_test.go index 757eb2f3d9..d6812f714e 100644 --- a/modules/indexer/issues/indexer_test.go +++ b/modules/indexer/issues/indexer_test.go @@ -50,21 +50,41 @@ func TestBleveSearchIssues(t *testing.T) { time.Sleep(5 * time.Second) - ids, err := SearchIssuesByKeyword(context.TODO(), []int64{1}, "issue2", "") - assert.NoError(t, err) - assert.EqualValues(t, []int64{2}, ids) + t.Run("issue2", func(t *testing.T) { + ids, _, err := SearchIssues(context.TODO(), &SearchOptions{ + Keyword: "issue2", + RepoIDs: []int64{1}, + }) + assert.NoError(t, err) + assert.EqualValues(t, []int64{2}, ids) + }) - ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "first", "") - assert.NoError(t, err) - assert.EqualValues(t, []int64{1}, ids) + t.Run("first", func(t *testing.T) { + ids, _, err := SearchIssues(context.TODO(), &SearchOptions{ + Keyword: "first", + RepoIDs: []int64{1}, + }) + assert.NoError(t, err) + assert.EqualValues(t, []int64{1}, ids) + }) - ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "for", "") - assert.NoError(t, err) - assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids) + t.Run("for", func(t *testing.T) { + ids, _, err := SearchIssues(context.TODO(), &SearchOptions{ + Keyword: "for", + RepoIDs: []int64{1}, + }) + assert.NoError(t, err) + assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids) + }) - ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "good", "") - assert.NoError(t, err) - assert.EqualValues(t, []int64{1}, ids) + t.Run("good", func(t *testing.T) { + ids, _, err := SearchIssues(context.TODO(), &SearchOptions{ + Keyword: "good", + RepoIDs: []int64{1}, + }) + assert.NoError(t, err) + assert.EqualValues(t, []int64{1}, ids) + }) } func TestDBSearchIssues(t *testing.T) { @@ -73,19 +93,39 @@ func TestDBSearchIssues(t *testing.T) { setting.Indexer.IssueType = "db" InitIssueIndexer(true) - ids, err := SearchIssuesByKeyword(context.TODO(), []int64{1}, "issue2", "") - assert.NoError(t, err) - assert.EqualValues(t, []int64{2}, ids) + t.Run("issue2", func(t *testing.T) { + ids, _, err := SearchIssues(context.TODO(), &SearchOptions{ + Keyword: "issue2", + RepoIDs: []int64{1}, + }) + assert.NoError(t, err) + assert.EqualValues(t, []int64{2}, ids) + }) - ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "first", "") - assert.NoError(t, err) - assert.EqualValues(t, []int64{1}, ids) + t.Run("first", func(t *testing.T) { + ids, _, err := SearchIssues(context.TODO(), &SearchOptions{ + Keyword: "first", + RepoIDs: []int64{1}, + }) + assert.NoError(t, err) + assert.EqualValues(t, []int64{1}, ids) + }) - ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "for", "") - assert.NoError(t, err) - assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids) + t.Run("for", func(t *testing.T) { + ids, _, err := SearchIssues(context.TODO(), &SearchOptions{ + Keyword: "for", + RepoIDs: []int64{1}, + }) + assert.NoError(t, err) + assert.ElementsMatch(t, []int64{1, 2, 3, 5, 11}, ids) + }) - ids, err = SearchIssuesByKeyword(context.TODO(), []int64{1}, "good", "") - assert.NoError(t, err) - assert.EqualValues(t, []int64{1}, ids) + t.Run("good", func(t *testing.T) { + ids, _, err := SearchIssues(context.TODO(), &SearchOptions{ + Keyword: "good", + RepoIDs: []int64{1}, + }) + assert.NoError(t, err) + assert.EqualValues(t, []int64{1}, ids) + }) } |