From d5d59a7cd0a5a054fa3562bf916e206a8823f403 Mon Sep 17 00:00:00 2001 From: Patrick Rice Date: Sun, 27 Feb 2022 23:50:39 +0000 Subject: [PATCH 1/3] Add file_template_project_id attribute to Group Struct Added a test to ensure that the value unmarshaled properly as well. --- groups.go | 1 + groups_test.go | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/groups.go b/groups.go index b3535ef72..172a5f767 100644 --- a/groups.go +++ b/groups.go @@ -71,6 +71,7 @@ type Group struct { LDAPCN string `json:"ldap_cn"` LDAPAccess AccessLevelValue `json:"ldap_access"` LDAPGroupLinks []*LDAPGroupLink `json:"ldap_group_links"` + FileTemplateProjectId int `json:"file_template_project_id"` SharedRunnersMinutesLimit int `json:"shared_runners_minutes_limit"` ExtraSharedRunnersMinutesLimit int `json:"extra_shared_runners_minutes_limit"` PreventForkingOutsideGroup bool `json:"prevent_forking_outside_group"` diff --git a/groups_test.go b/groups_test.go index e2e2b87b5..da09beb02 100644 --- a/groups_test.go +++ b/groups_test.go @@ -49,6 +49,28 @@ func TestGetGroup(t *testing.T) { } } +func TestGetGroupWithFileTemplateId(t *testing.T) { + mux, server, client := setup(t) + defer teardown(server) + + mux.HandleFunc("/api/v4/groups/g", + func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, http.MethodGet) + fmt.Fprint(w, `{"id": 1, "name": "g","file_template_project_id": 12345}`) + }) + + group, _, err := client.Groups.GetGroup("g", &GetGroupOptions{}) + if err != nil { + t.Errorf("Groups.GetGroup returned error: %v", err) + } + + want := &Group{ID: 1, Name: "g", FileTemplateProjectId: 12345} + if !reflect.DeepEqual(want, group) { + t.Errorf("Groups.GetGroup returned %+v, want %+v", group, want) + } + +} + func TestCreateGroup(t *testing.T) { mux, server, client := setup(t) defer teardown(server) From 707261f9191fc777a4daa4720bcc1877fb3b454e Mon Sep 17 00:00:00 2001 From: Patrick Rice Date: Mon, 28 Feb 2022 20:56:40 +0000 Subject: [PATCH 2/3] Re-position template_id, and fix capitalization --- groups.go | 2 +- groups_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/groups.go b/groups.go index 172a5f767..28174cb1b 100644 --- a/groups.go +++ b/groups.go @@ -47,6 +47,7 @@ type Group struct { RequestAccessEnabled bool `json:"request_access_enabled"` FullName string `json:"full_name"` FullPath string `json:"full_path"` + FileTemplateProjectID int `json:"file_template_project_id"` ParentID int `json:"parent_id"` Projects []*Project `json:"projects"` Statistics *StorageStatistics `json:"statistics"` @@ -71,7 +72,6 @@ type Group struct { LDAPCN string `json:"ldap_cn"` LDAPAccess AccessLevelValue `json:"ldap_access"` LDAPGroupLinks []*LDAPGroupLink `json:"ldap_group_links"` - FileTemplateProjectId int `json:"file_template_project_id"` SharedRunnersMinutesLimit int `json:"shared_runners_minutes_limit"` ExtraSharedRunnersMinutesLimit int `json:"extra_shared_runners_minutes_limit"` PreventForkingOutsideGroup bool `json:"prevent_forking_outside_group"` diff --git a/groups_test.go b/groups_test.go index da09beb02..f673bed8b 100644 --- a/groups_test.go +++ b/groups_test.go @@ -64,7 +64,7 @@ func TestGetGroupWithFileTemplateId(t *testing.T) { t.Errorf("Groups.GetGroup returned error: %v", err) } - want := &Group{ID: 1, Name: "g", FileTemplateProjectId: 12345} + want := &Group{ID: 1, Name: "g", FileTemplateProjectID: 12345} if !reflect.DeepEqual(want, group) { t.Errorf("Groups.GetGroup returned %+v, want %+v", group, want) } From d3eb6f893a79b53a2dd2e180f26b5cd837a24459 Mon Sep 17 00:00:00 2001 From: Patrick Rice Date: Tue, 1 Mar 2022 14:19:56 +0000 Subject: [PATCH 3/3] Fix unnecessary whitespace lint error --- groups_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/groups_test.go b/groups_test.go index f673bed8b..ccf0d82de 100644 --- a/groups_test.go +++ b/groups_test.go @@ -68,7 +68,6 @@ func TestGetGroupWithFileTemplateId(t *testing.T) { if !reflect.DeepEqual(want, group) { t.Errorf("Groups.GetGroup returned %+v, want %+v", group, want) } - } func TestCreateGroup(t *testing.T) {