summaryrefslogtreecommitdiffstats
path: root/services/repository/transfer_test.go
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/repository/transfer_test.go
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/repository/transfer_test.go')
-rw-r--r--services/repository/transfer_test.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/services/repository/transfer_test.go b/services/repository/transfer_test.go
index 9ce60f30ee..09c9829216 100644
--- a/services/repository/transfer_test.go
+++ b/services/repository/transfer_test.go
@@ -9,7 +9,6 @@ import (
"testing"
"code.gitea.io/gitea/models"
- "code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/notification/action"
@@ -31,12 +30,12 @@ func TestTransferOwnership(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
- repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
- repo.Owner = db.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
+ doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
+ repo.Owner = unittest.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
assert.NoError(t, TransferOwnership(doer, doer, repo, nil))
- transferredRepo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
+ transferredRepo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
assert.EqualValues(t, 2, transferredRepo.OwnerID)
exist, err := util.IsExist(models.RepoPath("user3", "repo3"))
@@ -45,23 +44,23 @@ func TestTransferOwnership(t *testing.T) {
exist, err = util.IsExist(models.RepoPath("user2", "repo3"))
assert.NoError(t, err)
assert.True(t, exist)
- db.AssertExistsAndLoadBean(t, &models.Action{
+ unittest.AssertExistsAndLoadBean(t, &models.Action{
OpType: models.ActionTransferRepo,
ActUserID: 2,
RepoID: 3,
Content: "user3/repo3",
})
- models.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{})
+ unittest.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{})
}
func TestStartRepositoryTransferSetPermission(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
- doer := db.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User)
- recipient := db.AssertExistsAndLoadBean(t, &models.User{ID: 5}).(*models.User)
- repo := db.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
- repo.Owner = db.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
+ doer := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 3}).(*models.User)
+ recipient := unittest.AssertExistsAndLoadBean(t, &models.User{ID: 5}).(*models.User)
+ repo := unittest.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
+ repo.Owner = unittest.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
hasAccess, err := models.HasAccess(recipient.ID, repo)
assert.NoError(t, err)
@@ -73,5 +72,5 @@ func TestStartRepositoryTransferSetPermission(t *testing.T) {
assert.NoError(t, err)
assert.True(t, hasAccess)
- models.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{})
+ unittest.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{})
}