@@ -26,14 +26,14 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
26262727 })
2828 convey .So (err , convey .ShouldBeNil )
29- convey .So (http . StatusOK , convey .ShouldEqual , resp . StatusCode )
29+ convey .So (resp . StatusCode , convey .ShouldEqual , http . StatusOK )
3030
3131 loginResp , err := client .Login (ctx , api.LoginJSONRequestBody {
3232 Username : userName ,
3333 Password : "12345678" ,
3434 })
3535 convey .So (err , convey .ShouldBeNil )
36- convey .So (http . StatusOK , convey .ShouldEqual , loginResp . StatusCode )
36+ convey .So (loginResp . StatusCode , convey .ShouldEqual , http . StatusOK )
3737
3838 client .RequestEditors = append (client .RequestEditors , func (ctx context.Context , req * http.Request ) error {
3939 for _ , cookie := range loginResp .Cookies () {
@@ -49,7 +49,7 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
4949 Name : "repo" ,
5050 })
5151 convey .So (err , convey .ShouldBeNil )
52- convey .So (http . StatusBadRequest , convey .ShouldEqual , resp . StatusCode )
52+ convey .So (resp . StatusCode , convey .ShouldEqual , http . StatusBadRequest )
5353 })
5454
5555 c .Convey ("success create repo name" , func () {
@@ -58,20 +58,29 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
5858 Name : "happyrun" ,
5959 })
6060 convey .So (err , convey .ShouldBeNil )
61- convey .So (http . StatusOK , convey .ShouldEqual , resp . StatusCode )
61+ convey .So (resp . StatusCode , convey .ShouldEqual , http . StatusOK )
6262
6363 grp , err := api .ParseGetRepositoryResponse (resp )
6464 convey .So (err , convey .ShouldBeNil )
65- convey .So (controller . DefaultBranchName , convey .ShouldEqual , grp . JSON200 . Head )
65+ convey .So (grp . JSON200 . Head , convey .ShouldEqual , controller . DefaultBranchName )
6666 fmt .Println (grp .JSON200 .ID )
6767 //check default branch created
6868 branchResp , err := client .GetBranch (ctx , userName , grp .JSON200 .Name , & api.GetBranchParams {RefName : controller .DefaultBranchName })
6969 convey .So (err , convey .ShouldBeNil )
70- convey .So (http . StatusOK , convey .ShouldEqual , branchResp . StatusCode )
70+ convey .So (branchResp . StatusCode , convey .ShouldEqual , http . StatusOK )
7171
7272 brp , err := api .ParseGetBranchResponse (branchResp )
7373 convey .So (err , convey .ShouldBeNil )
74- convey .So (controller .DefaultBranchName , convey .ShouldEqual , brp .JSON200 .Name )
74+ convey .So (brp .JSON200 .Name , convey .ShouldEqual , controller .DefaultBranchName )
75+ })
76+
77+ c .Convey ("add second repo " , func () {
78+ resp , err := client .CreateRepository (ctx , api.CreateRepository {
79+ Description : utils .String ("test resp" ),
80+ Name : "happygo" ,
81+ })
82+ convey .So (err , convey .ShouldBeNil )
83+ convey .So (resp .StatusCode , convey .ShouldEqual , http .StatusOK )
7584 })
7685
7786 c .Convey ("duplicate repo" , func () {
@@ -80,18 +89,40 @@ func RepoSpec(ctx context.Context, urlStr string) func(c convey.C) {
8089 Name : "happyrun" ,
8190 })
8291 convey .So (err , convey .ShouldBeNil )
83- convey .So (http . StatusInternalServerError , convey .ShouldEqual , resp . StatusCode )
92+ convey .So (resp . StatusCode , convey .ShouldEqual , http . StatusInternalServerError )
8493 })
8594
8695 c .Convey ("list repository" , func () {
87- resp , err := client .ListRepository (ctx , userName )
96+ resp , err := client .ListRepository (ctx , userName , & api.ListRepositoryParams {})
97+ convey .So (err , convey .ShouldBeNil )
98+ convey .So (resp .StatusCode , convey .ShouldEqual , http .StatusOK )
99+
100+ listRepos , err := api .ParseListRepositoryResponse (resp )
101+ convey .So (err , convey .ShouldBeNil )
102+
103+ convey .So (len (* listRepos .JSON200 ), convey .ShouldEqual , 2 )
104+ })
105+
106+ c .Convey ("list repository by prefix" , func () {
107+ resp , err := client .ListRepository (ctx , userName , & api.ListRepositoryParams {RepoPrefix : utils .String ("happy" )})
108+ convey .So (err , convey .ShouldBeNil )
109+ convey .So (resp .StatusCode , convey .ShouldEqual , http .StatusOK )
110+
111+ listRepos , err := api .ParseListRepositoryResponse (resp )
112+ convey .So (err , convey .ShouldBeNil )
113+
114+ convey .So (len (* listRepos .JSON200 ), convey .ShouldEqual , 2 )
115+ })
116+
117+ c .Convey ("list repository by prefix but found nothing" , func () {
118+ resp , err := client .ListRepository (ctx , userName , & api.ListRepositoryParams {RepoPrefix : utils .String ("bad" )})
88119 convey .So (err , convey .ShouldBeNil )
89- convey .So (http . StatusOK , convey .ShouldEqual , resp . StatusCode )
120+ convey .So (resp . StatusCode , convey .ShouldEqual , http . StatusOK )
90121
91122 listRepos , err := api .ParseListRepositoryResponse (resp )
92123 convey .So (err , convey .ShouldBeNil )
93124
94- convey .So (len (* listRepos .JSON200 ), convey .ShouldEqual , 1 )
125+ convey .So (len (* listRepos .JSON200 ), convey .ShouldEqual , 0 )
95126 })
96127 }
97128}
0 commit comments