|
|
|
@ -19,6 +19,7 @@ import ( |
|
|
|
|
_ "code.gitea.io/gitea/models/activities" |
|
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert" |
|
|
|
|
"github.com/stretchr/testify/require" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
func TestMain(m *testing.M) { |
|
|
|
@ -26,7 +27,7 @@ func TestMain(m *testing.M) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func TestDBSearchIssues(t *testing.T) { |
|
|
|
|
assert.NoError(t, unittest.PrepareTestDatabase()) |
|
|
|
|
require.NoError(t, unittest.PrepareTestDatabase()) |
|
|
|
|
|
|
|
|
|
setting.Indexer.IssueType = "db" |
|
|
|
|
InitIssueIndexer(true) |
|
|
|
@ -83,9 +84,7 @@ func searchIssueWithKeyword(t *testing.T) { |
|
|
|
|
|
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -120,9 +119,7 @@ func searchIssueByIndex(t *testing.T) { |
|
|
|
|
|
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -166,9 +163,7 @@ func searchIssueInRepo(t *testing.T) { |
|
|
|
|
|
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -238,9 +233,7 @@ func searchIssueByID(t *testing.T) { |
|
|
|
|
|
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -265,9 +258,7 @@ func searchIssueIsPull(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -292,9 +283,7 @@ func searchIssueIsClosed(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -319,9 +308,7 @@ func searchIssueIsArchived(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -346,9 +333,7 @@ func searchIssueByMilestoneID(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -379,9 +364,7 @@ func searchIssueByLabelID(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -400,9 +383,7 @@ func searchIssueByTime(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -421,9 +402,7 @@ func searchIssueWithOrder(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -454,9 +433,7 @@ func searchIssueInProject(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, _, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -479,9 +456,7 @@ func searchIssueWithPaginator(t *testing.T) { |
|
|
|
|
} |
|
|
|
|
for _, test := range tests { |
|
|
|
|
issueIDs, total, err := SearchIssues(context.TODO(), &test.opts) |
|
|
|
|
if !assert.NoError(t, err) { |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
require.NoError(t, err) |
|
|
|
|
assert.Equal(t, test.expectedIDs, issueIDs) |
|
|
|
|
assert.Equal(t, test.expectedTotal, total) |
|
|
|
|
} |
|
|
|
|