@@ -38,15 +38,15 @@ func TestGetGroup(t *testing.T) {
3838 mux .HandleFunc ("/api/v4/groups/g" ,
3939 func (w http.ResponseWriter , r * http.Request ) {
4040 testMethod (t , r , http .MethodGet )
41- fmt .Fprint (w , `{"id": 1, "name": "g"}` )
41+ fmt .Fprint (w , `{"id": 1, "name": "g", "default_branch": "branch" }` )
4242 })
4343
4444 group , _ , err := client .Groups .GetGroup ("g" , & GetGroupOptions {})
4545 if err != nil {
4646 t .Errorf ("Groups.GetGroup returned error: %v" , err )
4747 }
4848
49- want := & Group {ID : 1 , Name : "g" }
49+ want := & Group {ID : 1 , Name : "g" , DefaultBranch : "branch" }
5050 if ! reflect .DeepEqual (want , group ) {
5151 t .Errorf ("Groups.GetGroup returned %+v, want %+v" , group , want )
5252 }
@@ -97,6 +97,32 @@ func TestCreateGroup(t *testing.T) {
9797 }
9898}
9999
100+ func TestCreateGroupWithDefaultBranch (t * testing.T ) {
101+ mux , client := setup (t )
102+
103+ mux .HandleFunc ("/api/v4/groups" ,
104+ func (w http.ResponseWriter , r * http.Request ) {
105+ testMethod (t , r , http .MethodPost )
106+ fmt .Fprint (w , `{"id": 1, "name": "g", "path": "g", "default_branch": "branch"}` )
107+ })
108+
109+ opt := & CreateGroupOptions {
110+ Name : Ptr ("g" ),
111+ Path : Ptr ("g" ),
112+ DefaultBranch : Ptr ("branch" ),
113+ }
114+
115+ group , _ , err := client .Groups .CreateGroup (opt , nil )
116+ if err != nil {
117+ t .Errorf ("Groups.CreateGroup returned error: %v" , err )
118+ }
119+
120+ want := & Group {ID : 1 , Name : "g" , Path : "g" , DefaultBranch : "branch" }
121+ if ! reflect .DeepEqual (want , group ) {
122+ t .Errorf ("Groups.CreateGroup returned %+v, want %+v" , group , want )
123+ }
124+ }
125+
100126func TestCreateGroupDefaultBranchSettings (t * testing.T ) {
101127 mux , client := setup (t )
102128
@@ -326,6 +352,30 @@ func TestUpdateGroup(t *testing.T) {
326352 }
327353}
328354
355+ func TestUpdateGroupWithDefaultBranch (t * testing.T ) {
356+ mux , client := setup (t )
357+
358+ mux .HandleFunc ("/api/v4/groups/1" ,
359+ func (w http.ResponseWriter , r * http.Request ) {
360+ testMethod (t , r , http .MethodPut )
361+ fmt .Fprint (w , `{"id": 1, "default_branch": "branch"}` )
362+ })
363+
364+ opt := & UpdateGroupOptions {
365+ DefaultBranch : Ptr ("branch" ),
366+ }
367+
368+ group , _ , err := client .Groups .UpdateGroup (1 , opt )
369+ if err != nil {
370+ t .Errorf ("Groups.UpdateGroup returned error: %v" , err )
371+ }
372+
373+ want := & Group {ID : 1 , DefaultBranch : "branch" }
374+ if ! reflect .DeepEqual (want , group ) {
375+ t .Errorf ("Groups.UpdatedGroup returned %+v, want %+v" , group , want )
376+ }
377+ }
378+
329379func TestListGroupProjects (t * testing.T ) {
330380 mux , client := setup (t )
331381
0 commit comments