diff options
author | Ethan Koenig <ethantkoenig@gmail.com> | 2017-12-19 21:37:56 -0800 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-19 23:37:56 -0600 |
commit | e67b4055f9087cc381df437502f3cd912abb53ed (patch) | |
tree | 23311b0a8de60b596da9d0d2c67f2eec017453c4 /models/repo_test.go | |
parent | 7cf17e376ba06e246fb3143e94f3f4b8af259ae4 (diff) | |
download | gitea-e67b4055f9087cc381df437502f3cd912abb53ed.tar.gz gitea-e67b4055f9087cc381df437502f3cd912abb53ed.zip |
Fix repo-transfer-and-team-repo-count bug (#3241)
Diffstat (limited to 'models/repo_test.go')
-rw-r--r-- | models/repo_test.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/models/repo_test.go b/models/repo_test.go index 34eaa16c0b..752ffc2dd9 100644 --- a/models/repo_test.go +++ b/models/repo_test.go @@ -153,3 +153,26 @@ func TestRepoLocalCopyPath(t *testing.T) { setting.Repository.Local.LocalCopyPath = tempPath assert.Equal(t, expected, repo.LocalCopyPath()) } + +func TestTransferOwnership(t *testing.T) { + assert.NoError(t, PrepareTestDatabase()) + + doer := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User) + repo := AssertExistsAndLoadBean(t, &Repository{ID: 3}).(*Repository) + repo.Owner = AssertExistsAndLoadBean(t, &User{ID: repo.OwnerID}).(*User) + assert.NoError(t, TransferOwnership(doer, "user2", repo)) + + transferredRepo := AssertExistsAndLoadBean(t, &Repository{ID: 3}).(*Repository) + assert.EqualValues(t, 2, transferredRepo.OwnerID) + + assert.False(t, com.IsExist(RepoPath("user3", "repo3"))) + assert.True(t, com.IsExist(RepoPath("user2", "repo3"))) + AssertExistsAndLoadBean(t, &Action{ + OpType: ActionTransferRepo, + ActUserID: 2, + RepoID: 3, + Content: "user3/repo3", + }) + + CheckConsistencyFor(t, &Repository{}, &User{}, &Team{}) +} |