summaryrefslogtreecommitdiffstats
path: root/models/issue_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2019-02-21 13:01:28 +0800
committerGitHub <noreply@github.com>2019-02-21 13:01:28 +0800
commit477ef462510d69a8a31e008fb6e64059dc6cc148 (patch)
tree2c7884ad454e6301d71e6f5ed3fc2247a190dedc /models/issue_test.go
parent0751153613bfd2e39cf28e83bbe04b76641d222f (diff)
downloadgitea-477ef462510d69a8a31e008fb6e64059dc6cc148.tar.gz
gitea-477ef462510d69a8a31e008fb6e64059dc6cc148.zip
Add more tests and docs for issue indexer, add db indexer type for searching from database (#6144)
* add more tests and docs for issue indexer, add db indexer type for searching from database * fix typo * fix typo * fix lint * improve docs
Diffstat (limited to 'models/issue_test.go')
-rw-r--r--models/issue_test.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/models/issue_test.go b/models/issue_test.go
index cec7e8b478..1a7e45ae02 100644
--- a/models/issue_test.go
+++ b/models/issue_test.go
@@ -295,3 +295,28 @@ func TestIssue_loadTotalTimes(t *testing.T) {
assert.NoError(t, ms.loadTotalTimes(x))
assert.Equal(t, int64(3662), ms.TotalTrackedTime)
}
+
+func TestIssue_SearchIssueIDsByKeyword(t *testing.T) {
+ assert.NoError(t, PrepareTestDatabase())
+
+ total, ids, err := SearchIssueIDsByKeyword("issue2", 1, 10, 0)
+ assert.NoError(t, err)
+ assert.EqualValues(t, 1, total)
+ assert.EqualValues(t, []int64{2}, ids)
+
+ total, ids, err = SearchIssueIDsByKeyword("first", 1, 10, 0)
+ assert.NoError(t, err)
+ assert.EqualValues(t, 1, total)
+ assert.EqualValues(t, []int64{1}, ids)
+
+ total, ids, err = SearchIssueIDsByKeyword("for", 1, 10, 0)
+ assert.NoError(t, err)
+ assert.EqualValues(t, 4, total)
+ assert.EqualValues(t, []int64{1, 2, 3, 5}, ids)
+
+ // issue1's comment id 2
+ total, ids, err = SearchIssueIDsByKeyword("good", 1, 10, 0)
+ assert.NoError(t, err)
+ assert.EqualValues(t, 1, total)
+ assert.EqualValues(t, []int64{1}, ids)
+}