Skip to content

Commit ce94c31

Browse files
committed
fix bugs
1 parent 6b32640 commit ce94c31

File tree

4 files changed

+54
-24
lines changed

4 files changed

+54
-24
lines changed

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ github.com/RoaringBitmap/roaring v0.4.7 h1:eGUudvFzvF7Kxh7JjYvXfI1f7l22/2duFby7r
5050
github.com/RoaringBitmap/roaring v0.4.7/go.mod h1:8khRDP4HmeXns4xIj9oGrKSz7XTQiJx2zgh7AcNke4w=
5151
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
5252
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
53+
github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755 h1:1B7wb36fHLSwZfHg6ngZhhtIEHQjiC5H4p7qQGBEffg=
5354
github.com/Unknwon/com v0.0.0-20190321035513-0fed4efef755/go.mod h1:voKvFVpXBJxdIPeqjoJuLK+UVcRlo/JLjeToGxPYu68=
5455
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
5556
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/ghQa61ZWa/C2Aw3RkjiTBOix7dkqa1VLIs=

models/repo_test.go

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"code.gitea.io/gitea/modules/markup"
1616

1717
"github.com/stretchr/testify/assert"
18-
"github.com/unknwon/com"
1918
)
2019

2120
func TestRepo(t *testing.T) {
@@ -142,29 +141,6 @@ func TestRepoAPIURL(t *testing.T) {
142141
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user12/repo10", repo.APIURL())
143142
}
144143

145-
func TestTransferOwnership(t *testing.T) {
146-
assert.NoError(t, PrepareTestDatabase())
147-
148-
doer := AssertExistsAndLoadBean(t, &User{ID: 2}).(*User)
149-
repo := AssertExistsAndLoadBean(t, &Repository{ID: 3}).(*Repository)
150-
repo.Owner = AssertExistsAndLoadBean(t, &User{ID: repo.OwnerID}).(*User)
151-
assert.NoError(t, TransferOwnership(doer, "user2", repo))
152-
153-
transferredRepo := AssertExistsAndLoadBean(t, &Repository{ID: 3}).(*Repository)
154-
assert.EqualValues(t, 2, transferredRepo.OwnerID)
155-
156-
assert.False(t, com.IsExist(RepoPath("user3", "repo3")))
157-
assert.True(t, com.IsExist(RepoPath("user2", "repo3")))
158-
AssertExistsAndLoadBean(t, &Action{
159-
OpType: ActionTransferRepo,
160-
ActUserID: 2,
161-
RepoID: 3,
162-
Content: "user3/repo3",
163-
})
164-
165-
CheckConsistencyFor(t, &Repository{}, &User{}, &Team{})
166-
}
167-
168144
func TestUploadAvatar(t *testing.T) {
169145

170146
// Generate image

services/repository/main_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2019 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package mailer
6+
7+
import (
8+
"path/filepath"
9+
"testing"
10+
11+
"code.gitea.io/gitea/models"
12+
)
13+
14+
func TestMain(m *testing.M) {
15+
models.MainTest(m, filepath.Join("..", ".."))
16+
}

services/repository/transfer_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2019 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package repository
6+
7+
import (
8+
"testing"
9+
10+
"code.gitea.io/gitea/models"
11+
12+
"github.com/stretchr/testify/assert"
13+
"github.com/unknwon/com"
14+
)
15+
16+
func TestTransferOwnership(t *testing.T) {
17+
assert.NoError(t, models.PrepareTestDatabase())
18+
19+
doer := models.AssertExistsAndLoadBean(t, &models.User{ID: 2}).(*models.User)
20+
repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
21+
repo.Owner = models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
22+
assert.NoError(t, models.TransferOwnership(doer, "user2", repo))
23+
24+
transferredRepo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 3}).(*models.Repository)
25+
assert.EqualValues(t, 2, transferredRepo.OwnerID)
26+
27+
assert.False(t, com.IsExist(models.RepoPath("user3", "repo3")))
28+
assert.True(t, com.IsExist(models.RepoPath("user2", "repo3")))
29+
models.AssertExistsAndLoadBean(t, &models.Action{
30+
OpType: models.ActionTransferRepo,
31+
ActUserID: 2,
32+
RepoID: 3,
33+
Content: "user3/repo3",
34+
})
35+
36+
models.CheckConsistencyFor(t, &models.Repository{}, &models.User{}, &models.Team{})
37+
}

0 commit comments

Comments
 (0)