@@ -18,6 +18,7 @@ import (
18
18
19
19
"code.gitea.io/git"
20
20
"code.gitea.io/gitea/modules/setting"
21
+ api "code.gitea.io/sdk/gitea"
21
22
22
23
"github.com/Unknwon/com"
23
24
"github.com/stretchr/testify/assert"
@@ -48,17 +49,44 @@ func TestGit(t *testing.T) {
48
49
prepareTestEnv (t )
49
50
50
51
onGiteaWebRun (t , func (t * testing.T , u * url.URL ) {
51
- dstPath , err := ioutil .TempDir ("" , "repo1 " )
52
+ dstPath , err := ioutil .TempDir ("" , "repo-tmp-17 " )
52
53
assert .NoError (t , err )
53
54
defer os .RemoveAll (dstPath )
54
55
u .Path = "user2/repo1.git"
55
56
56
57
t .Run ("Standard" , func (t * testing.T ) {
58
+
57
59
t .Run ("CloneNoLogin" , func (t * testing.T ) {
60
+ dstLocalPath , err := ioutil .TempDir ("" , "repo1" )
61
+ assert .NoError (t , err )
62
+ defer os .RemoveAll (dstLocalPath )
63
+ err = git .Clone (u .String (), dstLocalPath , git.CloneRepoOptions {})
64
+ assert .NoError (t , err )
65
+ assert .True (t , com .IsExist (filepath .Join (dstLocalPath , "README.md" )))
66
+ })
67
+
68
+ t .Run ("CreateRepo" , func (t * testing.T ) {
69
+ session := loginUser (t , "user2" )
70
+ req := NewRequestWithJSON (t , "POST" , "/api/v1/user/repos" , & api.CreateRepoOption {
71
+ AutoInit : true ,
72
+ Description : "Temporary repo" ,
73
+ Name : "repo-tmp-17" ,
74
+ Private : false ,
75
+ Gitignores : "" ,
76
+ License : "WTFPL" ,
77
+ Readme : "Default" ,
78
+ })
79
+ session .MakeRequest (t , req , http .StatusCreated )
80
+ })
81
+
82
+ u .Path = "user2/repo-tmp-17.git"
83
+ u .User = url .UserPassword ("user2" , "password" )
84
+ t .Run ("Clone" , func (t * testing.T ) {
58
85
err = git .Clone (u .String (), dstPath , git.CloneRepoOptions {})
59
86
assert .NoError (t , err )
60
87
assert .True (t , com .IsExist (filepath .Join (dstPath , "README.md" )))
61
88
})
89
+
62
90
t .Run ("PushCommit" , func (t * testing.T ) {
63
91
data := make ([]byte , 1024 )
64
92
_ , err := rand .Read (data )
@@ -87,7 +115,6 @@ func TestGit(t *testing.T) {
87
115
assert .NoError (t , err )
88
116
89
117
//Push
90
- u .User = url .UserPassword ("user2" , "password" )
91
118
err = git .Push (dstPath , git.PushOptions {
92
119
Branch : "master" ,
93
120
Remote : u .String (),
0 commit comments