Skip to content

Commit 5f68d54

Browse files
authored
feat: Add support for team type field (#4037)
1 parent 27db7f9 commit 5f68d54

6 files changed

Lines changed: 36 additions & 10 deletions

File tree

github/copilot_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ func TestCopilotService_GetSeatDetailsTeam(t *testing.T) {
207207
}
208208

209209
want := &Team{
210-
ID: Ptr(int64(1)),
210+
ID: Ptr(int64(1)),
211+
Type: Ptr("Team"),
211212
}
212213

213214
if got, ok := seatDetails.GetTeam(); ok && !cmp.Equal(got, want) {
@@ -575,6 +576,7 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) {
575576
Assignee: &Team{
576577
ID: Ptr(int64(1)),
577578
Name: Ptr("octokittens"),
579+
Type: Ptr("Team"),
578580
},
579581
AssigningTeam: nil,
580582
CreatedAt: &createdAt2,
@@ -599,9 +601,7 @@ func TestCopilotService_ListCopilotSeats(t *testing.T) {
599601
},
600602
}
601603

602-
if !cmp.Equal(got, want) {
603-
t.Errorf("Copilot.ListCopilotSeats returned %+v, want %+v", got, want)
604-
}
604+
assertNoDiff(t, want, got)
605605

606606
const methodName = "ListCopilotSeats"
607607

github/github-accessors.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-stringify_test.go

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/teams.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ type Team struct {
6060
// possible values are: "direct", "indirect", "mixed". This is only populated when
6161
// calling the ListTeamsAssignedToOrgRole method.
6262
Assignment *string `json:"assignment,omitempty"`
63+
64+
// Type identifies the ownership type of the team
65+
// Possible values are: "organization", "enterprise".
66+
Type *string `json:"type,omitempty"`
6367
}
6468

6569
func (t Team) String() string {

github/teams_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func TestTeamsService_GetTeamByID(t *testing.T) {
6868

6969
mux.HandleFunc("/organizations/1/team/1", func(w http.ResponseWriter, r *http.Request) {
7070
testMethod(t, r, "GET")
71-
fmt.Fprint(w, `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p", "ldap_dn":"cn=n,ou=groups,dc=example,dc=com", "parent":null}`)
71+
fmt.Fprint(w, `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p", "ldap_dn":"cn=n,ou=groups,dc=example,dc=com", "type": "organization", "parent":null}`)
7272
})
7373

7474
ctx := t.Context()
@@ -77,7 +77,7 @@ func TestTeamsService_GetTeamByID(t *testing.T) {
7777
t.Errorf("Teams.GetTeamByID returned error: %v", err)
7878
}
7979

80-
want := &Team{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), URL: Ptr("u"), Slug: Ptr("s"), Permission: Ptr("p"), LDAPDN: Ptr("cn=n,ou=groups,dc=example,dc=com")}
80+
want := &Team{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), URL: Ptr("u"), Slug: Ptr("s"), Permission: Ptr("p"), LDAPDN: Ptr("cn=n,ou=groups,dc=example,dc=com"), Type: Ptr("organization")}
8181
if !cmp.Equal(team, want) {
8282
t.Errorf("Teams.GetTeamByID returned %+v, want %+v", team, want)
8383
}
@@ -125,7 +125,7 @@ func TestTeamsService_GetTeamBySlug(t *testing.T) {
125125

126126
mux.HandleFunc("/orgs/o/teams/s", func(w http.ResponseWriter, r *http.Request) {
127127
testMethod(t, r, "GET")
128-
fmt.Fprint(w, `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p", "ldap_dn":"cn=n,ou=groups,dc=example,dc=com", "parent":null}`)
128+
fmt.Fprint(w, `{"id":1, "name":"n", "description": "d", "url":"u", "slug": "s", "permission":"p", "ldap_dn":"cn=n,ou=groups,dc=example,dc=com", "type": "organization", "parent":null}`)
129129
})
130130

131131
ctx := t.Context()
@@ -134,7 +134,7 @@ func TestTeamsService_GetTeamBySlug(t *testing.T) {
134134
t.Errorf("Teams.GetTeamBySlug returned error: %v", err)
135135
}
136136

137-
want := &Team{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), URL: Ptr("u"), Slug: Ptr("s"), Permission: Ptr("p"), LDAPDN: Ptr("cn=n,ou=groups,dc=example,dc=com")}
137+
want := &Team{ID: Ptr(int64(1)), Name: Ptr("n"), Description: Ptr("d"), URL: Ptr("u"), Slug: Ptr("s"), Permission: Ptr("p"), LDAPDN: Ptr("cn=n,ou=groups,dc=example,dc=com"), Type: Ptr("organization")}
138138
if !cmp.Equal(team, want) {
139139
t.Errorf("Teams.GetTeamBySlug returned %+v, want %+v", team, want)
140140
}
@@ -1650,6 +1650,7 @@ func TestTeams_Marshal(t *testing.T) {
16501650
ReposCount: Ptr(1),
16511651
},
16521652
LDAPDN: Ptr("l"),
1653+
Type: Ptr("t"),
16531654
}
16541655

16551656
want := `{
@@ -1689,7 +1690,8 @@ func TestTeams_Marshal(t *testing.T) {
16891690
"members_count": 1,
16901691
"repos_count": 1
16911692
},
1692-
"ldap_dn": "l"
1693+
"ldap_dn": "l",
1694+
"type": "t"
16931695
}`
16941696

16951697
testJSONMarshal(t, u, want)

0 commit comments

Comments
 (0)