aboutsummaryrefslogtreecommitdiffstats
path: root/services/issue
diff options
context:
space:
mode:
authorwxiaoguang <wxiaoguang@gmail.com>2021-11-16 16:53:21 +0800
committerGitHub <noreply@github.com>2021-11-16 16:53:21 +0800
commit81926d61db3dac223a75ea49eab893b25a089587 (patch)
tree627d2f19a008089f3a688e9a94a2cc8d2017afe2 /services/issue
parent23bd7b1211a80aa3b0dcb60ec4a1c0089ff28dd4 (diff)
downloadgitea-81926d61db3dac223a75ea49eab893b25a089587.tar.gz
gitea-81926d61db3dac223a75ea49eab893b25a089587.zip
Decouple unit test, remove intermediate `unittestbridge` package (#17662)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'services/issue')
-rw-r--r--services/issue/label_test.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/services/issue/label_test.go b/services/issue/label_test.go
index 758ef98b27..fa6ad613b6 100644
--- a/services/issue/label_test.go
+++ b/services/issue/label_test.go
@@ -8,7 +8,6 @@ import (
"testing"
"code.gitea.io/gitea/models"
- "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest"
"github.com/stretchr/testify/assert"
)
@@ -26,15 +25,15 @@ func TestIssue_AddLabels(t *testing.T) {
}
for _, test := range tests {
assert.NoError(t, unittest.PrepareTestDatabase())
- issue := db.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue)
+ issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue)
labels := make([]*models.Label, len(test.labelIDs))
for i, labelID := range test.labelIDs {
- labels[i] = db.AssertExistsAndLoadBean(t, &models.Label{ID: labelID}).(*models.Label)
+ labels[i] = unittest.AssertExistsAndLoadBean(t, &models.Label{ID: labelID}).(*models.Label)
}
- doer := db.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User)
+ doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User)
assert.NoError(t, AddLabels(issue, doer, labels))
for _, labelID := range test.labelIDs {
- db.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: labelID})
+ unittest.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: labelID})
}
}
}
@@ -52,10 +51,10 @@ func TestIssue_AddLabel(t *testing.T) {
}
for _, test := range tests {
assert.NoError(t, unittest.PrepareTestDatabase())
- issue := db.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue)
- label := db.AssertExistsAndLoadBean(t, &models.Label{ID: test.labelID}).(*models.Label)
- doer := db.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User)
+ issue := unittest.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue)
+ label := unittest.AssertExistsAndLoadBean(t, &models.Label{ID: test.labelID}).(*models.Label)
+ doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: test.doerID}).(*models.User)
assert.NoError(t, AddLabel(issue, doer, label))
- db.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: test.labelID})
+ unittest.AssertExistsAndLoadBean(t, &models.IssueLabel{IssueID: test.issueID, LabelID: test.labelID})
}
}