|
|
|
@ -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{}) |
|
|
|
|
} |
|
|
|
|