From 1a0605d8ae10581a63c048dd17c15316f40254b5 Mon Sep 17 00:00:00 2001 From: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> Date: Mon, 25 Mar 2024 09:14:06 -0400 Subject: [PATCH] Add NotificationSetting to NewTeam Signed-off-by: Glenn Lewis <6598971+gmlewis@users.noreply.github.com> --- github/github-accessors.go | 8 ++++++++ github/github-accessors_test.go | 10 ++++++++++ github/github-stringify_test.go | 21 +++++++++++---------- github/teams.go | 3 +++ github/teams_test.go | 18 ++++++++++-------- 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index f95e4c3b9bd..57a7165f7ff 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -11982,6 +11982,14 @@ func (n *NewTeam) GetLDAPDN() string { return *n.LDAPDN } +// GetNotificationSetting returns the NotificationSetting field if it's non-nil, zero value otherwise. +func (n *NewTeam) GetNotificationSetting() string { + if n == nil || n.NotificationSetting == nil { + return "" + } + return *n.NotificationSetting +} + // GetParentTeamID returns the ParentTeamID field if it's non-nil, zero value otherwise. func (n *NewTeam) GetParentTeamID() int64 { if n == nil || n.ParentTeamID == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index ca263064ffb..bbf9fb8422c 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -13985,6 +13985,16 @@ func TestNewTeam_GetLDAPDN(tt *testing.T) { n.GetLDAPDN() } +func TestNewTeam_GetNotificationSetting(tt *testing.T) { + var zeroValue string + n := &NewTeam{NotificationSetting: &zeroValue} + n.GetNotificationSetting() + n = &NewTeam{} + n.GetNotificationSetting() + n = nil + n.GetNotificationSetting() +} + func TestNewTeam_GetParentTeamID(tt *testing.T) { var zeroValue int64 n := &NewTeam{ParentTeamID: &zeroValue} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 576db8ff29a..8633d837d12 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -962,16 +962,17 @@ func TestMilestoneStats_String(t *testing.T) { func TestNewTeam_String(t *testing.T) { v := NewTeam{ - Name: "", - Description: String(""), - Maintainers: []string{""}, - RepoNames: []string{""}, - ParentTeamID: Int64(0), - Permission: String(""), - Privacy: String(""), - LDAPDN: String(""), - } - want := `github.NewTeam{Name:"", Description:"", Maintainers:[""], RepoNames:[""], ParentTeamID:0, Permission:"", Privacy:"", LDAPDN:""}` + Name: "", + Description: String(""), + Maintainers: []string{""}, + RepoNames: []string{""}, + ParentTeamID: Int64(0), + NotificationSetting: String(""), + Permission: String(""), + Privacy: String(""), + LDAPDN: String(""), + } + want := `github.NewTeam{Name:"", Description:"", Maintainers:[""], RepoNames:[""], ParentTeamID:0, NotificationSetting:"", Permission:"", Privacy:"", LDAPDN:""}` if got := v.String(); got != want { t.Errorf("NewTeam.String = %v, want %v", got, want) } diff --git a/github/teams.go b/github/teams.go index fd22b792a66..0f6cc9d16e4 100644 --- a/github/teams.go +++ b/github/teams.go @@ -155,6 +155,9 @@ type NewTeam struct { RepoNames []string `json:"repo_names,omitempty"` ParentTeamID *int64 `json:"parent_team_id,omitempty"` + // NotificationSetting can be one of: "notifications_enabled", "notifications_disabled". + NotificationSetting *string `json:"notification_setting,omitempty"` + // Deprecated: Permission is deprecated when creating or editing a team in an org // using the new GitHub permission model. It no longer identifies the // permission a team has on its repos, but only specifies the default diff --git a/github/teams_test.go b/github/teams_test.go index c0ca1f6dd71..516c88f43ae 100644 --- a/github/teams_test.go +++ b/github/teams_test.go @@ -1590,14 +1590,15 @@ func TestNewTeam_Marshal(t *testing.T) { testJSONMarshal(t, &NewTeam{}, "{}") u := &NewTeam{ - Name: "n", - Description: String("d"), - Maintainers: []string{"m1", "m2"}, - RepoNames: []string{"repo1", "repo2"}, - ParentTeamID: Int64(1), - Permission: String("perm"), - Privacy: String("p"), - LDAPDN: String("l"), + Name: "n", + Description: String("d"), + Maintainers: []string{"m1", "m2"}, + RepoNames: []string{"repo1", "repo2"}, + NotificationSetting: String("notifications_enabled"), + ParentTeamID: Int64(1), + Permission: String("perm"), + Privacy: String("p"), + LDAPDN: String("l"), } want := `{ @@ -1606,6 +1607,7 @@ func TestNewTeam_Marshal(t *testing.T) { "maintainers": ["m1", "m2"], "repo_names": ["repo1", "repo2"], "parent_team_id": 1, + "notification_setting": "notifications_enabled", "permission": "perm", "privacy": "p", "ldap_dn": "l"