From 74b3db54cfcc1c11f4bbeee2150625bdb187ad70 Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sat, 21 Jan 2017 11:51:08 +0530 Subject: [PATCH 01/12] #514: added inviter to Invitation for orgs and teams invite --- github/orgs_teams.go | 28 +++++++++++++++++- github/orgs_teams_test.go | 62 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 87 insertions(+), 3 deletions(-) diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 6afcd1f2ee2..29ad4a85937 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -50,13 +50,39 @@ type Invitation struct { Login *string `json:"login,omitempty"` Email *string `json:"email,omitempty"` Role *string `json:"role,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` + CreatedAt time.Time `json:"created_at,omitempty"` + Inviter *Inviter `json:"inviter,omitempty"` } func (i Invitation) String() string { return Stringify(i) } +// Inviter represents the entity introduced in team and org invitations +type Inviter struct { + Login *string `json:"login,omitempty"` + ID *int `json:"id,omitempty"` + Avatar_url *string `json:"avatar_url,omitempty"` + Gravatar_id *string `json:"gravatar_id,omitempty"` + Url *string `json:"url,omit_empty"` + Html_url *string `json:"html_url,omitempty"` + Followers_url *string `json:"followers_url,omitempty"` + Following_url *string `json:"following_url,omitempty"` + Gists_url *string `json:"gists_url,omitempty"` + Starred_url *string `json:"starred_url,omitempty"` + Subscriptions_url *string `json:"subscriptions_url,omitempty"` + Organizations_url *string `json:"organizations_url,omitempty"` + Repos_url *string `json:"repos_url,omitempty"` + Events_url *string `json:"events_url,omitempty"` + Received_events_url *string `json:"received_events_url,omitempty"` + Type *string `json:"type,omitempty"` + Site_admin bool `json:"site_admin,omitempty"` +} + +func (i Inviter) String() string { + return Stringify(i) +} + // ListTeams lists all of the teams for an organization. // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-teams diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 96cf82d6321..63e6d0f6fda 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -8,6 +8,7 @@ package github import ( "encoding/json" "fmt" +// "time" "net/http" "reflect" "testing" @@ -500,6 +501,7 @@ func TestOrganizationsService_ListUserTeams(t *testing.T) { } } +//"created_at": "2016-11-30T06:46:10-08:00", func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { setup() defer teardown() @@ -508,7 +510,33 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { testMethod(t, r, "GET") testFormValues(t, r, values{"page": "1"}) testHeader(t, r, "Accept", mediaTypeOrgMembershipPreview) - fmt.Fprint(w, `[{"id":1}]`) + fmt.Fprint(w, `[ + { + "id": 1, + "login": "monalisa", + "email": "octocat@github.com", + "role": "direct_member", + "inviter": { + "login": "other_user", + "id": 1, + "avatar_url": "https://github.com/images/error/other_user_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/other_user", + "html_url": "https://github.com/other_user", + "followers_url": "https://api.github.com/users/other_user/followers", + "following_url": "https://api.github.com/users/other_user/following/other_user", + "gists_url": "https://api.github.com/users/other_user/gists/gist_id", + "starred_url": "https://api.github.com/users/other_user/starred/owner/repo", + "subscriptions_url": "https://api.github.com/users/other_user/subscriptions", + "organizations_url": "https://api.github.com/users/other_user/orgs", + "repos_url": "https://api.github.com/users/other_user/repos", + "events_url": "https://api.github.com/users/other_user/events/privacy", + "received_events_url": "https://api.github.com/users/other_user/received_events/privacy", + "type": "User", + "site_admin": false + } + } + ]`) }) opt := &ListOptions{Page: 1} @@ -517,7 +545,37 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { t.Errorf("Organizations.ListPendingTeamInvitations returned error: %v", err) } - want := []*Invitation{{ID: Int(1)}} + //layout := "2006-01-02T15:04:05.000Z" + //strCreatedAt := "2016-11-30T06:46:10-08:00" + //tmCreatedAt, err := time.Parse(layout, strCreatedAt) + want := []*Invitation{ + { + ID: Int(1), + Login: String("monalisa"), + Email: String("octocat@github.com"), + Role: String("direct_member"), + // CreatedAt: tmCreatedAt, + Inviter: &Inviter{ + Login: String("other_user"), + ID: Int(1), + Avatar_url: String("https://github.com/images/error/other_user_happy.gif"), + Gravatar_id: String(""), + Url: String("https://api.github.com/users/other_user"), + Html_url: String("https://github.com/other_user"), + Followers_url: String("https://api.github.com/users/other_user/followers"), + Following_url: String("https://api.github.com/users/other_user/following/other_user"), + Gists_url: String("https://api.github.com/users/other_user/gists/gist_id"), + Starred_url: String("https://api.github.com/users/other_user/starred/owner/repo"), + Subscriptions_url: String("https://api.github.com/users/other_user/subscriptions"), + Organizations_url: String("https://api.github.com/users/other_user/orgs"), + Repos_url: String("https://api.github.com/users/other_user/repos"), + Events_url: String("https://api.github.com/users/other_user/events/privacy"), + Received_events_url: String("https://api.github.com/users/other_user/received_events/privacy"), + Type: String("User"), + Site_admin: false, + }, + }} + fmt.Println("DEBUG %v", want[0]) if !reflect.DeepEqual(invitations, want) { t.Errorf("Organizations.ListPendingTeamInvitations returned %+v, want %+v", invitations, want) } From 4a4a270f22aa5971ef0930bc1858c2f2992aafe5 Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sat, 21 Jan 2017 12:02:29 +0530 Subject: [PATCH 02/12] #514: go fmt --- github/orgs_teams.go | 10 +++++----- github/orgs_teams_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 29ad4a85937..b08226ffa86 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -46,12 +46,12 @@ func (t Team) String() string { // Invitation represents a team member's inviation status type Invitation struct { - ID *int `json:"id,omitempty"` - Login *string `json:"login,omitempty"` - Email *string `json:"email,omitempty"` - Role *string `json:"role,omitempty"` + ID *int `json:"id,omitempty"` + Login *string `json:"login,omitempty"` + Email *string `json:"email,omitempty"` + Role *string `json:"role,omitempty"` CreatedAt time.Time `json:"created_at,omitempty"` - Inviter *Inviter `json:"inviter,omitempty"` + Inviter *Inviter `json:"inviter,omitempty"` } func (i Invitation) String() string { diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 63e6d0f6fda..ab9046cb72c 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -8,7 +8,7 @@ package github import ( "encoding/json" "fmt" -// "time" + // "time" "net/http" "reflect" "testing" @@ -554,7 +554,7 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { Login: String("monalisa"), Email: String("octocat@github.com"), Role: String("direct_member"), - // CreatedAt: tmCreatedAt, + // CreatedAt: tmCreatedAt, Inviter: &Inviter{ Login: String("other_user"), ID: Int(1), From 3f2f969944feb4d9039ff69f9692db18ec24128a Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sat, 21 Jan 2017 12:07:57 +0530 Subject: [PATCH 03/12] #514: removed prints --- github/orgs_teams_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index ab9046cb72c..78fbfd8f4e4 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -575,7 +575,7 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { Site_admin: false, }, }} - fmt.Println("DEBUG %v", want[0]) + if !reflect.DeepEqual(invitations, want) { t.Errorf("Organizations.ListPendingTeamInvitations returned %+v, want %+v", invitations, want) } From 1d7107abc2620958186284dfa34e9d5b2f608aaf Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sat, 21 Jan 2017 14:46:37 +0530 Subject: [PATCH 04/12] #514: changed time data types and included them in test --- github/orgs_teams.go | 11 +++++++---- github/orgs_teams_test.go | 17 +++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/github/orgs_teams.go b/github/orgs_teams.go index b08226ffa86..522e4155d27 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -46,10 +46,13 @@ func (t Team) String() string { // Invitation represents a team member's inviation status type Invitation struct { - ID *int `json:"id,omitempty"` - Login *string `json:"login,omitempty"` - Email *string `json:"email,omitempty"` - Role *string `json:"role,omitempty"` + ID *int `json:"id,omitempty"` + Login *string `json:"login,omitempty"` + Email *string `json:"email,omitempty"` + Role *string `json:"role,omitempty"` + //golang documentation states + //Programs using times should typically store and pass them as values, not pointers. + //That is, time variables and struct fields should be of type time.Time, not *time.Time CreatedAt time.Time `json:"created_at,omitempty"` Inviter *Inviter `json:"inviter,omitempty"` } diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 78fbfd8f4e4..f091d708cd7 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -8,10 +8,10 @@ package github import ( "encoding/json" "fmt" - // "time" "net/http" "reflect" "testing" + "time" ) func TestOrganizationsService_ListTeams(t *testing.T) { @@ -501,7 +501,6 @@ func TestOrganizationsService_ListUserTeams(t *testing.T) { } } -//"created_at": "2016-11-30T06:46:10-08:00", func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { setup() defer teardown() @@ -516,6 +515,7 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { "login": "monalisa", "email": "octocat@github.com", "role": "direct_member", + "created_at": "2017-01-21T00:00:00Z", "inviter": { "login": "other_user", "id": 1, @@ -545,16 +545,13 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { t.Errorf("Organizations.ListPendingTeamInvitations returned error: %v", err) } - //layout := "2006-01-02T15:04:05.000Z" - //strCreatedAt := "2016-11-30T06:46:10-08:00" - //tmCreatedAt, err := time.Parse(layout, strCreatedAt) want := []*Invitation{ { - ID: Int(1), - Login: String("monalisa"), - Email: String("octocat@github.com"), - Role: String("direct_member"), - // CreatedAt: tmCreatedAt, + ID: Int(1), + Login: String("monalisa"), + Email: String("octocat@github.com"), + Role: String("direct_member"), + CreatedAt: time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC), Inviter: &Inviter{ Login: String("other_user"), ID: Int(1), From f5b2eeb0adebeef670586d175f213ddf8c08c580 Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sat, 21 Jan 2017 16:52:59 +0530 Subject: [PATCH 05/12] #514 Added Org List Pending Invitations --- github/orgs_members.go | 30 ++++++++++++++ github/orgs_members_test.go | 78 +++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) diff --git a/github/orgs_members.go b/github/orgs_members.go index 80454ada0cd..957674c97ab 100644 --- a/github/orgs_members.go +++ b/github/orgs_members.go @@ -270,3 +270,33 @@ func (s *OrganizationsService) RemoveOrgMembership(user, org string) (*Response, return s.client.Do(req, nil) } + +//ListPendingOrgInvitations returns a list of contains a role field which refers to the +//Organization Invitation role and will be one of the following values: +//direct_member, admin, billing_manager, hiring_manager, or reinstate. +//If the invitee is not a GitHub member, the login field in the return hash will be null. +// +// GitHub API docs: +// https://developer.github.com/v3/orgs/members/#list-pending-organization-invitations +func (s *OrganizationsService) ListPendingOrgInvitations(org int, opt *ListOptions) ([]*Invitation, *Response, error) { + u := fmt.Sprintf("orgs/%v/invitations", org) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeOrgMembershipPreview) + + pendingInvitations := new([]*Invitation) + resp, err := s.client.Do(req, pendingInvitations) + if err != nil { + return nil, resp, err + } + return *pendingInvitations, resp, err +} diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index f95e5be6dd5..f0b3fc4de43 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -11,6 +11,7 @@ import ( "net/http" "reflect" "testing" + "time" ) func TestOrganizationsService_ListMembers(t *testing.T) { @@ -353,3 +354,80 @@ func TestOrganizationsService_RemoveOrgMembership(t *testing.T) { t.Errorf("Organizations.RemoveOrgMembership returned error: %v", err) } } + +func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/orgs/1/invitations", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{"page": "1"}) + testHeader(t, r, "Accept", mediaTypeOrgMembershipPreview) + fmt.Fprint(w, `[ + { + "id": 1, + "login": "monalisa", + "email": "octocat@github.com", + "role": "direct_member", + "created_at": "2017-01-21T00:00:00Z", + "inviter": { + "login": "other_user", + "id": 1, + "avatar_url": "https://github.com/images/error/other_user_happy.gif", + "gravatar_id": "", + "url": "https://api.github.com/users/other_user", + "html_url": "https://github.com/other_user", + "followers_url": "https://api.github.com/users/other_user/followers", + "following_url": "https://api.github.com/users/other_user/following/other_user", + "gists_url": "https://api.github.com/users/other_user/gists/gist_id", + "starred_url": "https://api.github.com/users/other_user/starred/owner/repo", + "subscriptions_url": "https://api.github.com/users/other_user/subscriptions", + "organizations_url": "https://api.github.com/users/other_user/orgs", + "repos_url": "https://api.github.com/users/other_user/repos", + "events_url": "https://api.github.com/users/other_user/events/privacy", + "received_events_url": "https://api.github.com/users/other_user/received_events/privacy", + "type": "User", + "site_admin": false + } + } + ]`) + }) + + opt := &ListOptions{Page: 1} + invitations, _, err := client.Organizations.ListPendingOrgInvitations(1, opt) + if err != nil { + t.Errorf("Organizations.ListPendingTeamInvitations returned error: %v", err) + } + + want := []*Invitation{ + { + ID: Int(1), + Login: String("monalisa"), + Email: String("octocat@github.com"), + Role: String("direct_member"), + CreatedAt: time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC), + Inviter: &Inviter{ + Login: String("other_user"), + ID: Int(1), + Avatar_url: String("https://github.com/images/error/other_user_happy.gif"), + Gravatar_id: String(""), + Url: String("https://api.github.com/users/other_user"), + Html_url: String("https://github.com/other_user"), + Followers_url: String("https://api.github.com/users/other_user/followers"), + Following_url: String("https://api.github.com/users/other_user/following/other_user"), + Gists_url: String("https://api.github.com/users/other_user/gists/gist_id"), + Starred_url: String("https://api.github.com/users/other_user/starred/owner/repo"), + Subscriptions_url: String("https://api.github.com/users/other_user/subscriptions"), + Organizations_url: String("https://api.github.com/users/other_user/orgs"), + Repos_url: String("https://api.github.com/users/other_user/repos"), + Events_url: String("https://api.github.com/users/other_user/events/privacy"), + Received_events_url: String("https://api.github.com/users/other_user/received_events/privacy"), + Type: String("User"), + Site_admin: false, + }, + }} + + if !reflect.DeepEqual(invitations, want) { + t.Errorf("Organizations.ListPendingTeamInvitations returned %+v, want %+v", invitations, want) + } +} From 112d7183dfecfa43e8a7f9b18fd85a35d18b8e2e Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sat, 21 Jan 2017 17:00:17 +0530 Subject: [PATCH 06/12] #514 removed typos in error handling --- github/orgs_members_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index f0b3fc4de43..038a7cfb7f7 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -396,7 +396,7 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { opt := &ListOptions{Page: 1} invitations, _, err := client.Organizations.ListPendingOrgInvitations(1, opt) if err != nil { - t.Errorf("Organizations.ListPendingTeamInvitations returned error: %v", err) + t.Errorf("Organizations.ListPendingOrgInvitations returned error: %v", err) } want := []*Invitation{ @@ -428,6 +428,6 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { }} if !reflect.DeepEqual(invitations, want) { - t.Errorf("Organizations.ListPendingTeamInvitations returned %+v, want %+v", invitations, want) + t.Errorf("Organizations.ListPendingOrgInvitations returned %+v, want %+v", invitations, want) } } From 2a95ca6a76e2704cf2142f2d68e61ba1dc5c844e Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sat, 28 Jan 2017 21:00:17 +0530 Subject: [PATCH 07/12] #514: Modified to pointer time.Time in Invitation --- github/orgs_members.go | 8 ++------ github/orgs_members_test.go | 3 ++- github/orgs_teams.go | 20 +++++++++----------- github/orgs_teams_test.go | 3 ++- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/github/orgs_members.go b/github/orgs_members.go index 957674c97ab..77f691276c0 100644 --- a/github/orgs_members.go +++ b/github/orgs_members.go @@ -271,13 +271,9 @@ func (s *OrganizationsService) RemoveOrgMembership(user, org string) (*Response, return s.client.Do(req, nil) } -//ListPendingOrgInvitations returns a list of contains a role field which refers to the -//Organization Invitation role and will be one of the following values: -//direct_member, admin, billing_manager, hiring_manager, or reinstate. -//If the invitee is not a GitHub member, the login field in the return hash will be null. +// ListPendingOrgInvitations returns a list of pending invitations. // -// GitHub API docs: -// https://developer.github.com/v3/orgs/members/#list-pending-organization-invitations +// GitHub API docs: https://developer.github.com/v3/orgs/members/#list-pending-organization-invitations func (s *OrganizationsService) ListPendingOrgInvitations(org int, opt *ListOptions) ([]*Invitation, *Response, error) { u := fmt.Sprintf("orgs/%v/invitations", org) u, err := addOptions(u, opt) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 038a7cfb7f7..90658edfe72 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -399,13 +399,14 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { t.Errorf("Organizations.ListPendingOrgInvitations returned error: %v", err) } + tm := time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC) want := []*Invitation{ { ID: Int(1), Login: String("monalisa"), Email: String("octocat@github.com"), Role: String("direct_member"), - CreatedAt: time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC), + CreatedAt: &tm, Inviter: &Inviter{ Login: String("other_user"), ID: Int(1), diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 522e4155d27..7e61b8f1438 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -44,24 +44,22 @@ func (t Team) String() string { return Stringify(t) } -// Invitation represents a team member's inviation status +// Invitation represents a team member's invitation status. +// Role can be one of the values - direct_member, admin, billing_manager, hiring_manager, or reinstate. type Invitation struct { - ID *int `json:"id,omitempty"` - Login *string `json:"login,omitempty"` - Email *string `json:"email,omitempty"` - Role *string `json:"role,omitempty"` - //golang documentation states - //Programs using times should typically store and pass them as values, not pointers. - //That is, time variables and struct fields should be of type time.Time, not *time.Time - CreatedAt time.Time `json:"created_at,omitempty"` - Inviter *Inviter `json:"inviter,omitempty"` + ID *int `json:"id,omitempty"` + Login *string `json:"login,omitempty"` + Email *string `json:"email,omitempty"` + Role *string `json:"role,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + Inviter *Inviter `json:"inviter,omitempty"` } func (i Invitation) String() string { return Stringify(i) } -// Inviter represents the entity introduced in team and org invitations +// Inviter represents the entity introduced in team and organization invitations. type Inviter struct { Login *string `json:"login,omitempty"` ID *int `json:"id,omitempty"` diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index f091d708cd7..78bcbbc28eb 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -545,13 +545,14 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { t.Errorf("Organizations.ListPendingTeamInvitations returned error: %v", err) } + tm := time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC) want := []*Invitation{ { ID: Int(1), Login: String("monalisa"), Email: String("octocat@github.com"), Role: String("direct_member"), - CreatedAt: time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC), + CreatedAt: &tm, Inviter: &Inviter{ Login: String("other_user"), ID: Int(1), From 6305685d0eb60893b104063862fb5d8d48cf480c Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sun, 29 Jan 2017 12:57:27 +0530 Subject: [PATCH 08/12] #514: Set up Naming conventions for multi words, pointer to bool --- github/orgs_members_test.go | 32 ++++++++++++++++---------------- github/orgs_teams.go | 36 ++++++++++++++++++------------------ github/orgs_teams_test.go | 32 ++++++++++++++++---------------- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 90658edfe72..0cd81616310 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -399,32 +399,32 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { t.Errorf("Organizations.ListPendingOrgInvitations returned error: %v", err) } - tm := time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC) + createdAt := time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC) want := []*Invitation{ { ID: Int(1), Login: String("monalisa"), Email: String("octocat@github.com"), Role: String("direct_member"), - CreatedAt: &tm, + CreatedAt: &createdAt, Inviter: &Inviter{ Login: String("other_user"), ID: Int(1), - Avatar_url: String("https://github.com/images/error/other_user_happy.gif"), - Gravatar_id: String(""), - Url: String("https://api.github.com/users/other_user"), - Html_url: String("https://github.com/other_user"), - Followers_url: String("https://api.github.com/users/other_user/followers"), - Following_url: String("https://api.github.com/users/other_user/following/other_user"), - Gists_url: String("https://api.github.com/users/other_user/gists/gist_id"), - Starred_url: String("https://api.github.com/users/other_user/starred/owner/repo"), - Subscriptions_url: String("https://api.github.com/users/other_user/subscriptions"), - Organizations_url: String("https://api.github.com/users/other_user/orgs"), - Repos_url: String("https://api.github.com/users/other_user/repos"), - Events_url: String("https://api.github.com/users/other_user/events/privacy"), - Received_events_url: String("https://api.github.com/users/other_user/received_events/privacy"), + Avatar_URL: String("https://github.com/images/error/other_user_happy.gif"), + Gravatar_ID: String(""), + URL: String("https://api.github.com/users/other_user"), + HTML_URL: String("https://github.com/other_user"), + Followers_URL: String("https://api.github.com/users/other_user/followers"), + Following_URL: String("https://api.github.com/users/other_user/following/other_user"), + Gists_URL: String("https://api.github.com/users/other_user/gists/gist_id"), + Starred_URL: String("https://api.github.com/users/other_user/starred/owner/repo"), + Subscriptions_URL: String("https://api.github.com/users/other_user/subscriptions"), + Organizations_URL: String("https://api.github.com/users/other_user/orgs"), + Repos_URL: String("https://api.github.com/users/other_user/repos"), + Events_URL: String("https://api.github.com/users/other_user/events/privacy"), + Received_events_URL: String("https://api.github.com/users/other_user/received_events/privacy"), Type: String("User"), - Site_admin: false, + Site_admin: Bool(false), }, }} diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 7e61b8f1438..13df5c5c61d 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -45,11 +45,11 @@ func (t Team) String() string { } // Invitation represents a team member's invitation status. -// Role can be one of the values - direct_member, admin, billing_manager, hiring_manager, or reinstate. type Invitation struct { - ID *int `json:"id,omitempty"` - Login *string `json:"login,omitempty"` - Email *string `json:"email,omitempty"` + ID *int `json:"id,omitempty"` + Login *string `json:"login,omitempty"` + Email *string `json:"email,omitempty"` + // Role can be one of the values - direct_member, admin, billing_manager, hiring_manager, or reinstate. Role *string `json:"role,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` Inviter *Inviter `json:"inviter,omitempty"` @@ -63,21 +63,21 @@ func (i Invitation) String() string { type Inviter struct { Login *string `json:"login,omitempty"` ID *int `json:"id,omitempty"` - Avatar_url *string `json:"avatar_url,omitempty"` - Gravatar_id *string `json:"gravatar_id,omitempty"` - Url *string `json:"url,omit_empty"` - Html_url *string `json:"html_url,omitempty"` - Followers_url *string `json:"followers_url,omitempty"` - Following_url *string `json:"following_url,omitempty"` - Gists_url *string `json:"gists_url,omitempty"` - Starred_url *string `json:"starred_url,omitempty"` - Subscriptions_url *string `json:"subscriptions_url,omitempty"` - Organizations_url *string `json:"organizations_url,omitempty"` - Repos_url *string `json:"repos_url,omitempty"` - Events_url *string `json:"events_url,omitempty"` - Received_events_url *string `json:"received_events_url,omitempty"` + Avatar_URL *string `json:"avatar_url,omitempty"` + Gravatar_ID *string `json:"gravatar_id,omitempty"` + URL *string `json:"url,omit_empty"` + HTML_URL *string `json:"html_url,omitempty"` + Followers_URL *string `json:"followers_url,omitempty"` + Following_URL *string `json:"following_url,omitempty"` + Gists_URL *string `json:"gists_url,omitempty"` + Starred_URL *string `json:"starred_url,omitempty"` + Subscriptions_URL *string `json:"subscriptions_url,omitempty"` + Organizations_URL *string `json:"organizations_url,omitempty"` + Repos_URL *string `json:"repos_url,omitempty"` + Events_URL *string `json:"events_url,omitempty"` + Received_events_URL *string `json:"received_events_url,omitempty"` Type *string `json:"type,omitempty"` - Site_admin bool `json:"site_admin,omitempty"` + Site_admin *bool `json:"site_admin,omitempty"` } func (i Inviter) String() string { diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 78bcbbc28eb..861998292e4 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -545,32 +545,32 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { t.Errorf("Organizations.ListPendingTeamInvitations returned error: %v", err) } - tm := time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC) + createdAt := time.Date(2017, 01, 21, 0, 0, 0, 0, time.UTC) want := []*Invitation{ { ID: Int(1), Login: String("monalisa"), Email: String("octocat@github.com"), Role: String("direct_member"), - CreatedAt: &tm, + CreatedAt: &createdAt, Inviter: &Inviter{ Login: String("other_user"), ID: Int(1), - Avatar_url: String("https://github.com/images/error/other_user_happy.gif"), - Gravatar_id: String(""), - Url: String("https://api.github.com/users/other_user"), - Html_url: String("https://github.com/other_user"), - Followers_url: String("https://api.github.com/users/other_user/followers"), - Following_url: String("https://api.github.com/users/other_user/following/other_user"), - Gists_url: String("https://api.github.com/users/other_user/gists/gist_id"), - Starred_url: String("https://api.github.com/users/other_user/starred/owner/repo"), - Subscriptions_url: String("https://api.github.com/users/other_user/subscriptions"), - Organizations_url: String("https://api.github.com/users/other_user/orgs"), - Repos_url: String("https://api.github.com/users/other_user/repos"), - Events_url: String("https://api.github.com/users/other_user/events/privacy"), - Received_events_url: String("https://api.github.com/users/other_user/received_events/privacy"), + Avatar_URL: String("https://github.com/images/error/other_user_happy.gif"), + Gravatar_ID: String(""), + URL: String("https://api.github.com/users/other_user"), + HTML_URL: String("https://github.com/other_user"), + Followers_URL: String("https://api.github.com/users/other_user/followers"), + Following_URL: String("https://api.github.com/users/other_user/following/other_user"), + Gists_URL: String("https://api.github.com/users/other_user/gists/gist_id"), + Starred_URL: String("https://api.github.com/users/other_user/starred/owner/repo"), + Subscriptions_URL: String("https://api.github.com/users/other_user/subscriptions"), + Organizations_URL: String("https://api.github.com/users/other_user/orgs"), + Repos_URL: String("https://api.github.com/users/other_user/repos"), + Events_URL: String("https://api.github.com/users/other_user/events/privacy"), + Received_events_URL: String("https://api.github.com/users/other_user/received_events/privacy"), Type: String("User"), - Site_admin: false, + Site_admin: Bool(false), }, }} From 1840a0097e2fa13149208e230058e09144074b75 Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Sun, 29 Jan 2017 13:09:13 +0530 Subject: [PATCH 09/12] #514: multi word variable format --- github/orgs_members_test.go | 34 +++++++++++++++++----------------- github/orgs_teams.go | 34 +++++++++++++++++----------------- github/orgs_teams_test.go | 34 +++++++++++++++++----------------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 0cd81616310..d8e7450fcce 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -408,23 +408,23 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { Role: String("direct_member"), CreatedAt: &createdAt, Inviter: &Inviter{ - Login: String("other_user"), - ID: Int(1), - Avatar_URL: String("https://github.com/images/error/other_user_happy.gif"), - Gravatar_ID: String(""), - URL: String("https://api.github.com/users/other_user"), - HTML_URL: String("https://github.com/other_user"), - Followers_URL: String("https://api.github.com/users/other_user/followers"), - Following_URL: String("https://api.github.com/users/other_user/following/other_user"), - Gists_URL: String("https://api.github.com/users/other_user/gists/gist_id"), - Starred_URL: String("https://api.github.com/users/other_user/starred/owner/repo"), - Subscriptions_URL: String("https://api.github.com/users/other_user/subscriptions"), - Organizations_URL: String("https://api.github.com/users/other_user/orgs"), - Repos_URL: String("https://api.github.com/users/other_user/repos"), - Events_URL: String("https://api.github.com/users/other_user/events/privacy"), - Received_events_URL: String("https://api.github.com/users/other_user/received_events/privacy"), - Type: String("User"), - Site_admin: Bool(false), + Login: String("other_user"), + ID: Int(1), + AvatarURL: String("https://github.com/images/error/other_user_happy.gif"), + GravatarID: String(""), + URL: String("https://api.github.com/users/other_user"), + HTMLURL: String("https://github.com/other_user"), + FollowersURL: String("https://api.github.com/users/other_user/followers"), + FollowingURL: String("https://api.github.com/users/other_user/following/other_user"), + GistsURL: String("https://api.github.com/users/other_user/gists/gist_id"), + StarredURL: String("https://api.github.com/users/other_user/starred/owner/repo"), + SubscriptionsURL: String("https://api.github.com/users/other_user/subscriptions"), + OrganizationsURL: String("https://api.github.com/users/other_user/orgs"), + ReposURL: String("https://api.github.com/users/other_user/repos"), + EventsURL: String("https://api.github.com/users/other_user/events/privacy"), + ReceivedEventsURL: String("https://api.github.com/users/other_user/received_events/privacy"), + Type: String("User"), + SiteAdmin: Bool(false), }, }} diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 13df5c5c61d..835b25d8ea2 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -61,23 +61,23 @@ func (i Invitation) String() string { // Inviter represents the entity introduced in team and organization invitations. type Inviter struct { - Login *string `json:"login,omitempty"` - ID *int `json:"id,omitempty"` - Avatar_URL *string `json:"avatar_url,omitempty"` - Gravatar_ID *string `json:"gravatar_id,omitempty"` - URL *string `json:"url,omit_empty"` - HTML_URL *string `json:"html_url,omitempty"` - Followers_URL *string `json:"followers_url,omitempty"` - Following_URL *string `json:"following_url,omitempty"` - Gists_URL *string `json:"gists_url,omitempty"` - Starred_URL *string `json:"starred_url,omitempty"` - Subscriptions_URL *string `json:"subscriptions_url,omitempty"` - Organizations_URL *string `json:"organizations_url,omitempty"` - Repos_URL *string `json:"repos_url,omitempty"` - Events_URL *string `json:"events_url,omitempty"` - Received_events_URL *string `json:"received_events_url,omitempty"` - Type *string `json:"type,omitempty"` - Site_admin *bool `json:"site_admin,omitempty"` + Login *string `json:"login,omitempty"` + ID *int `json:"id,omitempty"` + AvatarURL *string `json:"avatar_url,omitempty"` + GravatarID *string `json:"gravatar_id,omitempty"` + URL *string `json:"url,omit_empty"` + HTMLURL *string `json:"html_url,omitempty"` + FollowersURL *string `json:"followers_url,omitempty"` + FollowingURL *string `json:"following_url,omitempty"` + GistsURL *string `json:"gists_url,omitempty"` + StarredURL *string `json:"starred_url,omitempty"` + SubscriptionsURL *string `json:"subscriptions_url,omitempty"` + OrganizationsURL *string `json:"organizations_url,omitempty"` + ReposURL *string `json:"repos_url,omitempty"` + EventsURL *string `json:"events_url,omitempty"` + ReceivedEventsURL *string `json:"received_events_url,omitempty"` + Type *string `json:"type,omitempty"` + SiteAdmin *bool `json:"site_admin,omitempty"` } func (i Inviter) String() string { diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 861998292e4..fe777cf0772 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -554,23 +554,23 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { Role: String("direct_member"), CreatedAt: &createdAt, Inviter: &Inviter{ - Login: String("other_user"), - ID: Int(1), - Avatar_URL: String("https://github.com/images/error/other_user_happy.gif"), - Gravatar_ID: String(""), - URL: String("https://api.github.com/users/other_user"), - HTML_URL: String("https://github.com/other_user"), - Followers_URL: String("https://api.github.com/users/other_user/followers"), - Following_URL: String("https://api.github.com/users/other_user/following/other_user"), - Gists_URL: String("https://api.github.com/users/other_user/gists/gist_id"), - Starred_URL: String("https://api.github.com/users/other_user/starred/owner/repo"), - Subscriptions_URL: String("https://api.github.com/users/other_user/subscriptions"), - Organizations_URL: String("https://api.github.com/users/other_user/orgs"), - Repos_URL: String("https://api.github.com/users/other_user/repos"), - Events_URL: String("https://api.github.com/users/other_user/events/privacy"), - Received_events_URL: String("https://api.github.com/users/other_user/received_events/privacy"), - Type: String("User"), - Site_admin: Bool(false), + Login: String("other_user"), + ID: Int(1), + AvatarURL: String("https://github.com/images/error/other_user_happy.gif"), + GravatarID: String(""), + URL: String("https://api.github.com/users/other_user"), + HTMLURL: String("https://github.com/other_user"), + FollowersURL: String("https://api.github.com/users/other_user/followers"), + FollowingURL: String("https://api.github.com/users/other_user/following/other_user"), + GistsURL: String("https://api.github.com/users/other_user/gists/gist_id"), + StarredURL: String("https://api.github.com/users/other_user/starred/owner/repo"), + SubscriptionsURL: String("https://api.github.com/users/other_user/subscriptions"), + OrganizationsURL: String("https://api.github.com/users/other_user/orgs"), + ReposURL: String("https://api.github.com/users/other_user/repos"), + EventsURL: String("https://api.github.com/users/other_user/events/privacy"), + ReceivedEventsURL: String("https://api.github.com/users/other_user/received_events/privacy"), + Type: String("User"), + SiteAdmin: Bool(false), }, }} From 5c4cab8ec095916363168bd493669293d34865f1 Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Mon, 30 Jan 2017 20:42:26 +0530 Subject: [PATCH 10/12] #514 : used User instead of new struct --- github/orgs_members_test.go | 2 +- github/orgs_teams.go | 2 +- github/orgs_teams_test.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index d8e7450fcce..8a3ff3df560 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -407,7 +407,7 @@ func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { Email: String("octocat@github.com"), Role: String("direct_member"), CreatedAt: &createdAt, - Inviter: &Inviter{ + Inviter: &User{ Login: String("other_user"), ID: Int(1), AvatarURL: String("https://github.com/images/error/other_user_happy.gif"), diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 835b25d8ea2..700e5e339c5 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -52,7 +52,7 @@ type Invitation struct { // Role can be one of the values - direct_member, admin, billing_manager, hiring_manager, or reinstate. Role *string `json:"role,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` - Inviter *Inviter `json:"inviter,omitempty"` + Inviter *User `json:"inviter,omitempty"` } func (i Invitation) String() string { diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index fe777cf0772..36701f1a456 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -553,7 +553,7 @@ func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { Email: String("octocat@github.com"), Role: String("direct_member"), CreatedAt: &createdAt, - Inviter: &Inviter{ + Inviter: &User{ Login: String("other_user"), ID: Int(1), AvatarURL: String("https://github.com/images/error/other_user_happy.gif"), From e732a048ff745c49c717f2911abaff2adccd69a9 Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Mon, 30 Jan 2017 20:51:16 +0530 Subject: [PATCH 11/12] #514 : removed Inviter struct --- github/orgs_teams.go | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 700e5e339c5..10cd4caa167 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -59,31 +59,6 @@ func (i Invitation) String() string { return Stringify(i) } -// Inviter represents the entity introduced in team and organization invitations. -type Inviter struct { - Login *string `json:"login,omitempty"` - ID *int `json:"id,omitempty"` - AvatarURL *string `json:"avatar_url,omitempty"` - GravatarID *string `json:"gravatar_id,omitempty"` - URL *string `json:"url,omit_empty"` - HTMLURL *string `json:"html_url,omitempty"` - FollowersURL *string `json:"followers_url,omitempty"` - FollowingURL *string `json:"following_url,omitempty"` - GistsURL *string `json:"gists_url,omitempty"` - StarredURL *string `json:"starred_url,omitempty"` - SubscriptionsURL *string `json:"subscriptions_url,omitempty"` - OrganizationsURL *string `json:"organizations_url,omitempty"` - ReposURL *string `json:"repos_url,omitempty"` - EventsURL *string `json:"events_url,omitempty"` - ReceivedEventsURL *string `json:"received_events_url,omitempty"` - Type *string `json:"type,omitempty"` - SiteAdmin *bool `json:"site_admin,omitempty"` -} - -func (i Inviter) String() string { - return Stringify(i) -} - // ListTeams lists all of the teams for an organization. // // GitHub API docs: http://developer.github.com/v3/orgs/teams/#list-teams From 1bd4328a520dfc6d58f92e0f441f3f56718b725d Mon Sep 17 00:00:00 2001 From: Varadarajan Aravamudhan Date: Tue, 31 Jan 2017 23:19:39 +0530 Subject: [PATCH 12/12] #514: Added quotes to list values in comment --- github/orgs_teams.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/orgs_teams.go b/github/orgs_teams.go index 10cd4caa167..6ef5000b281 100644 --- a/github/orgs_teams.go +++ b/github/orgs_teams.go @@ -49,7 +49,7 @@ type Invitation struct { ID *int `json:"id,omitempty"` Login *string `json:"login,omitempty"` Email *string `json:"email,omitempty"` - // Role can be one of the values - direct_member, admin, billing_manager, hiring_manager, or reinstate. + // Role can be one of the values - 'direct_member', 'admin', 'billing_manager', 'hiring_manager', or 'reinstate'. Role *string `json:"role,omitempty"` CreatedAt *time.Time `json:"created_at,omitempty"` Inviter *User `json:"inviter,omitempty"`