diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2021-11-12 22:36:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-12 22:36:47 +0800 |
commit | df64fa486555de6f403a795fd16c2e9e1d59e535 (patch) | |
tree | b899e9b9e5d57409b1bf0e3afbd606b6a3900235 /services/issue | |
parent | 7f802631c54d2e91301158380b273b872d62bd80 (diff) | |
download | gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.tar.gz gitea-df64fa486555de6f403a795fd16c2e9e1d59e535.zip |
Decouple unit test code from business code (#17623)
Diffstat (limited to 'services/issue')
-rw-r--r-- | services/issue/assignee_test.go | 4 | ||||
-rw-r--r-- | services/issue/label_test.go | 5 | ||||
-rw-r--r-- | services/issue/main_test.go | 4 |
3 files changed, 7 insertions, 6 deletions
diff --git a/services/issue/assignee_test.go b/services/issue/assignee_test.go index 5684ed6d89..b0bbe42273 100644 --- a/services/issue/assignee_test.go +++ b/services/issue/assignee_test.go @@ -8,12 +8,12 @@ import ( "testing" "code.gitea.io/gitea/models" - "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" "github.com/stretchr/testify/assert" ) func TestDeleteNotPassedAssignee(t *testing.T) { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) // Fake issue with assignees issue, err := models.GetIssueWithAttrsByID(1) diff --git a/services/issue/label_test.go b/services/issue/label_test.go index 8a3a77ecb0..758ef98b27 100644 --- a/services/issue/label_test.go +++ b/services/issue/label_test.go @@ -9,6 +9,7 @@ import ( "code.gitea.io/gitea/models" "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" "github.com/stretchr/testify/assert" ) @@ -24,7 +25,7 @@ func TestIssue_AddLabels(t *testing.T) { {2, []int64{}, 1}, // pull-request, empty } for _, test := range tests { - assert.NoError(t, db.PrepareTestDatabase()) + assert.NoError(t, unittest.PrepareTestDatabase()) issue := db.AssertExistsAndLoadBean(t, &models.Issue{ID: test.issueID}).(*models.Issue) labels := make([]*models.Label, len(test.labelIDs)) for i, labelID := range test.labelIDs { @@ -50,7 +51,7 @@ func TestIssue_AddLabel(t *testing.T) { {2, 1, 2}, // pull-request, already-added label } for _, test := range tests { - assert.NoError(t, db.PrepareTestDatabase()) + 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) diff --git a/services/issue/main_test.go b/services/issue/main_test.go index 1349837949..cbcfd08a49 100644 --- a/services/issue/main_test.go +++ b/services/issue/main_test.go @@ -8,9 +8,9 @@ import ( "path/filepath" "testing" - "code.gitea.io/gitea/models/db" + "code.gitea.io/gitea/models/unittest" ) func TestMain(m *testing.M) { - db.MainTest(m, filepath.Join("..", "..")) + unittest.MainTest(m, filepath.Join("..", "..")) } |