Skip to content

Commit

Permalink
Migrate IDs to int64 type
Browse files Browse the repository at this point in the history
In this commit, the complete migration of all the struct IDs(which refer
to GitHub IDs) from platform dependent `int` type to the signed `int64`
takes place.

A helper function "Int64" is also implemented to assist the migration of
unit tests.

Refer google#597
  • Loading branch information
Kshitij Saraogi authored and Kshitij Saraogi committed Dec 23, 2017
1 parent 1acce21 commit de3d136
Show file tree
Hide file tree
Showing 83 changed files with 655 additions and 651 deletions.
6 changes: 3 additions & 3 deletions github/activity_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) {
t.Errorf("Activities.ListIssueEventsForRepository returned error: %v", err)
}

want := []*IssueEvent{{ID: Int(1)}, {ID: Int(2)}}
want := []*IssueEvent{{ID: Int64(1)}, {ID: Int64(2)}}
if !reflect.DeepEqual(events, want) {
t.Errorf("Activities.ListIssueEventsForRepository returned %+v, want %+v", events, want)
}
Expand Down Expand Up @@ -301,7 +301,7 @@ func TestActivityService_EventParsePayload_typed(t *testing.T) {
t.Fatalf("Unmarshal Event returned error: %v", err)
}

want := &PushEvent{PushID: Int(1)}
want := &PushEvent{PushID: Int64(1)}
got, err := event.ParsePayload()
if err != nil {
t.Fatalf("ParsePayload returned unexpected error: %v", err)
Expand Down Expand Up @@ -338,7 +338,7 @@ func TestActivityService_EventParsePayload_installation(t *testing.T) {
t.Fatalf("Unmarshal Event returned error: %v", err)
}

want := &PullRequestEvent{Installation: &Installation{ID: Int(1)}}
want := &PullRequestEvent{Installation: &Installation{ID: Int64(1)}}
got, err := event.ParsePayload()
if err != nil {
t.Fatalf("ParsePayload returned unexpected error: %v", err)
Expand Down
6 changes: 3 additions & 3 deletions github/activity_star_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestActivityService_ListStargazers(t *testing.T) {
t.Errorf("Activity.ListStargazers returned error: %v", err)
}

want := []*Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Int(1)}}}
want := []*Stargazer{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, User: &User{ID: Int64(1)}}}
if !reflect.DeepEqual(stargazers, want) {
t.Errorf("Activity.ListStargazers returned %+v, want %+v", stargazers, want)
}
Expand All @@ -54,7 +54,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) {
t.Errorf("Activity.ListStarred returned error: %v", err)
}

want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(1)}}}
want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int64(1)}}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
}
Expand All @@ -81,7 +81,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
t.Errorf("Activity.ListStarred returned error: %v", err)
}

want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(2)}}}
want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int64(2)}}}
if !reflect.DeepEqual(repos, want) {
t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
}
Expand Down
6 changes: 3 additions & 3 deletions github/activity_watching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestActivityService_ListWatchers(t *testing.T) {
t.Errorf("Activity.ListWatchers returned error: %v", err)
}

want := []*User{{ID: Int(1)}}
want := []*User{{ID: Int64(1)}}
if !reflect.DeepEqual(watchers, want) {
t.Errorf("Activity.ListWatchers returned %+v, want %+v", watchers, want)
}
Expand All @@ -55,7 +55,7 @@ func TestActivityService_ListWatched_authenticatedUser(t *testing.T) {
t.Errorf("Activity.ListWatched returned error: %v", err)
}

want := []*Repository{{ID: Int(1)}}
want := []*Repository{{ID: Int64(1)}}
if !reflect.DeepEqual(watched, want) {
t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want)
}
Expand All @@ -78,7 +78,7 @@ func TestActivityService_ListWatched_specifiedUser(t *testing.T) {
t.Errorf("Activity.ListWatched returned error: %v", err)
}

want := []*Repository{{ID: Int(1)}}
want := []*Repository{{ID: Int64(1)}}
if !reflect.DeepEqual(watched, want) {
t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want)
}
Expand Down
6 changes: 3 additions & 3 deletions github/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type AdminService service

// TeamLDAPMapping represents the mapping between a GitHub team and an LDAP group.
type TeamLDAPMapping struct {
ID *int `json:"id,omitempty"`
ID *int64 `json:"id,omitempty"`
LDAPDN *string `json:"ldap_dn,omitempty"`
URL *string `json:"url,omitempty"`
Name *string `json:"name,omitempty"`
Expand All @@ -38,7 +38,7 @@ func (m TeamLDAPMapping) String() string {

// UserLDAPMapping represents the mapping between a GitHub user and an LDAP user.
type UserLDAPMapping struct {
ID *int `json:"id,omitempty"`
ID *int64 `json:"id,omitempty"`
LDAPDN *string `json:"ldap_dn,omitempty"`
Login *string `json:"login,omitempty"`
AvatarURL *string `json:"avatar_url,omitempty"`
Expand Down Expand Up @@ -84,7 +84,7 @@ func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, m
// UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group.
//
// GitHub API docs: https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-team
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team)
req, err := s.client.NewRequest("PATCH", u, mapping)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions github/admin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func TestAdminService_UpdateUserLDAPMapping(t *testing.T) {
}

want := &UserLDAPMapping{
ID: Int(1),
ID: Int64(1),
LDAPDN: String("uid=asdf,ou=users,dc=github,dc=com"),
}
if !reflect.DeepEqual(mapping, want) {
Expand Down Expand Up @@ -72,7 +72,7 @@ func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) {
}

want := &TeamLDAPMapping{
ID: Int(1),
ID: Int64(1),
LDAPDN: String("cn=Enterprise Ops,ou=teams,dc=github,dc=com"),
}
if !reflect.DeepEqual(mapping, want) {
Expand Down
6 changes: 3 additions & 3 deletions github/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type AppsService service

// App represents a GitHub App.
type App struct {
ID *int `json:"id,omitempty"`
ID *int64 `json:"id,omitempty"`
Owner *User `json:"owner,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Expand Down Expand Up @@ -97,7 +97,7 @@ func (s *AppsService) ListInstallations(ctx context.Context, opt *ListOptions) (
// GetInstallation returns the specified installation.
//
// GitHub API docs: https://developer.github.com/v3/apps/#get-a-single-installation
func (s *AppsService) GetInstallation(ctx context.Context, id int) (*Installation, *Response, error) {
func (s *AppsService) GetInstallation(ctx context.Context, id int64) (*Installation, *Response, error) {
u := fmt.Sprintf("app/installations/%v", id)

req, err := s.client.NewRequest("GET", u, nil)
Expand Down Expand Up @@ -148,7 +148,7 @@ func (s *AppsService) ListUserInstallations(ctx context.Context, opt *ListOption
// CreateInstallationToken creates a new installation token.
//
// GitHub API docs: https://developer.github.com/v3/apps/#create-a-new-installation-token
func (s *AppsService) CreateInstallationToken(ctx context.Context, id int) (*InstallationToken, *Response, error) {
func (s *AppsService) CreateInstallationToken(ctx context.Context, id int64) (*InstallationToken, *Response, error) {
u := fmt.Sprintf("installations/%v/access_tokens", id)

req, err := s.client.NewRequest("POST", u, nil)
Expand Down
8 changes: 4 additions & 4 deletions github/apps_installation.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

// Installation represents a GitHub Apps installation.
type Installation struct {
ID *int `json:"id,omitempty"`
ID *int64 `json:"id,omitempty"`
Account *User `json:"account,omitempty"`
AccessTokensURL *string `json:"access_tokens_url,omitempty"`
RepositoriesURL *string `json:"repositories_url,omitempty"`
Expand Down Expand Up @@ -55,7 +55,7 @@ func (s *AppsService) ListRepos(ctx context.Context, opt *ListOptions) ([]*Repos
// to the authenticated user for an installation.
//
// GitHub API docs: https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation
func (s *AppsService) ListUserRepos(ctx context.Context, id int, opt *ListOptions) ([]*Repository, *Response, error) {
func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opt *ListOptions) ([]*Repository, *Response, error) {
u := fmt.Sprintf("user/installations/%v/repositories", id)
u, err := addOptions(u, opt)
if err != nil {
Expand Down Expand Up @@ -84,7 +84,7 @@ func (s *AppsService) ListUserRepos(ctx context.Context, id int, opt *ListOption
// AddRepository adds a single repository to an installation.
//
// GitHub API docs: https://developer.github.com/v3/apps/installations/#add-repository-to-installation
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int) (*Repository, *Response, error) {
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error) {
u := fmt.Sprintf("apps/installations/%v/repositories/%v", instID, repoID)
req, err := s.client.NewRequest("PUT", u, nil)
if err != nil {
Expand All @@ -103,7 +103,7 @@ func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int) (*R
// RemoveRepository removes a single repository from an installation.
//
// GitHub docs: https://developer.github.com/v3/apps/installations/#remove-repository-from-installation
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int) (*Response, error) {
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error) {
u := fmt.Sprintf("apps/installations/%v/repositories/%v", instID, repoID)
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions github/apps_installation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAppsService_ListRepos(t *testing.T) {
t.Errorf("Apps.ListRepos returned error: %v", err)
}

want := []*Repository{{ID: Int(1)}}
want := []*Repository{{ID: Int64(1)}}
if !reflect.DeepEqual(repositories, want) {
t.Errorf("Apps.ListRepos returned %+v, want %+v", repositories, want)
}
Expand All @@ -59,7 +59,7 @@ func TestAppsService_ListUserRepos(t *testing.T) {
t.Errorf("Apps.ListUserRepos returned error: %v", err)
}

want := []*Repository{{ID: Int(1)}}
want := []*Repository{{ID: Int64(1)}}
if !reflect.DeepEqual(repositories, want) {
t.Errorf("Apps.ListUserRepos returned %+v, want %+v", repositories, want)
}
Expand All @@ -79,7 +79,7 @@ func TestAppsService_AddRepository(t *testing.T) {
t.Errorf("Apps.AddRepository returned error: %v", err)
}

want := &Repository{ID: Int(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}}
want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}}
if !reflect.DeepEqual(repo, want) {
t.Errorf("AddRepository returned %+v, want %+v", repo, want)
}
Expand Down
8 changes: 4 additions & 4 deletions github/apps_marketplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type MarketplaceService struct {
type MarketplacePlan struct {
URL *string `json:"url,omitempty"`
AccountsURL *string `json:"accounts_url,omitempty"`
ID *int `json:"id,omitempty"`
ID *int64 `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
MonthlyPriceInCents *int `json:"monthly_price_in_cents,omitempty"`
Expand All @@ -52,7 +52,7 @@ type MarketplacePurchase struct {
type MarketplacePlanAccount struct {
URL *string `json:"url,omitempty"`
Type *string `json:"type,omitempty"`
ID *int `json:"id,omitempty"`
ID *int64 `json:"id,omitempty"`
Login *string `json:"login,omitempty"`
Email *string `json:"email,omitempty"`
OrganizationBillingEmail *string `json:"organization_billing_email,omitempty"`
Expand Down Expand Up @@ -89,7 +89,7 @@ func (s *MarketplaceService) ListPlans(ctx context.Context, opt *ListOptions) ([
// ListPlanAccountsForPlan lists all GitHub accounts (user or organization) on a specific plan.
//
// GitHub API docs: https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan
func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int, opt *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int64, opt *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
uri := s.marketplaceURI(fmt.Sprintf("plans/%v/accounts", planID))
u, err := addOptions(uri, opt)
if err != nil {
Expand All @@ -116,7 +116,7 @@ func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID
// ListPlanAccountsForAccount lists all GitHub accounts (user or organization) associated with an account.
//
// GitHub API docs: https://developer.github.com/v3/apps/marketplace/#check-if-a-github-account-is-associated-with-any-marketplace-listing
func (s *MarketplaceService) ListPlanAccountsForAccount(ctx context.Context, accountID int, opt *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
func (s *MarketplaceService) ListPlanAccountsForAccount(ctx context.Context, accountID int64, opt *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
uri := s.marketplaceURI(fmt.Sprintf("accounts/%v", accountID))
u, err := addOptions(uri, opt)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions github/apps_marketplace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestMarketplaceService_ListPlans(t *testing.T) {
t.Errorf("Marketplace.ListPlans returned error: %v", err)
}

want := []*MarketplacePlan{{ID: Int(1)}}
want := []*MarketplacePlan{{ID: Int64(1)}}
if !reflect.DeepEqual(plans, want) {
t.Errorf("Marketplace.ListPlans returned %+v, want %+v", plans, want)
}
Expand All @@ -57,7 +57,7 @@ func TestMarketplaceService_Stubbed_ListPlans(t *testing.T) {
t.Errorf("Marketplace.ListPlans (Stubbed) returned error: %v", err)
}

want := []*MarketplacePlan{{ID: Int(1)}}
want := []*MarketplacePlan{{ID: Int64(1)}}
if !reflect.DeepEqual(plans, want) {
t.Errorf("Marketplace.ListPlans (Stubbed) returned %+v, want %+v", plans, want)
}
Expand All @@ -80,7 +80,7 @@ func TestMarketplaceService_ListPlanAccountsForPlan(t *testing.T) {
t.Errorf("Marketplace.ListPlanAccountsForPlan returned error: %v", err)
}

want := []*MarketplacePlanAccount{{ID: Int(1)}}
want := []*MarketplacePlanAccount{{ID: Int64(1)}}
if !reflect.DeepEqual(accounts, want) {
t.Errorf("Marketplace.ListPlanAccountsForPlan returned %+v, want %+v", accounts, want)
}
Expand All @@ -103,7 +103,7 @@ func TestMarketplaceService_Stubbed_ListPlanAccountsForPlan(t *testing.T) {
t.Errorf("Marketplace.ListPlanAccountsForPlan (Stubbed) returned error: %v", err)
}

want := []*MarketplacePlanAccount{{ID: Int(1)}}
want := []*MarketplacePlanAccount{{ID: Int64(1)}}
if !reflect.DeepEqual(accounts, want) {
t.Errorf("Marketplace.ListPlanAccountsForPlan (Stubbed) returned %+v, want %+v", accounts, want)
}
Expand All @@ -126,7 +126,7 @@ func TestMarketplaceService_ListPlanAccountsForAccount(t *testing.T) {
t.Errorf("Marketplace.ListPlanAccountsForAccount returned error: %v", err)
}

want := []*MarketplacePlanAccount{{ID: Int(1)}}
want := []*MarketplacePlanAccount{{ID: Int64(1)}}
if !reflect.DeepEqual(accounts, want) {
t.Errorf("Marketplace.ListPlanAccountsForAccount returned %+v, want %+v", accounts, want)
}
Expand All @@ -149,7 +149,7 @@ func TestMarketplaceService_Stubbed_ListPlanAccountsForAccount(t *testing.T) {
t.Errorf("Marketplace.ListPlanAccountsForAccount (Stubbed) returned error: %v", err)
}

want := []*MarketplacePlanAccount{{ID: Int(1)}}
want := []*MarketplacePlanAccount{{ID: Int64(1)}}
if !reflect.DeepEqual(accounts, want) {
t.Errorf("Marketplace.ListPlanAccountsForAccount (Stubbed) returned %+v, want %+v", accounts, want)
}
Expand Down
8 changes: 4 additions & 4 deletions github/apps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestAppsService_Get_authenticatedApp(t *testing.T) {
t.Errorf("Apps.Get returned error: %v", err)
}

want := &App{ID: Int(1)}
want := &App{ID: Int64(1)}
if !reflect.DeepEqual(app, want) {
t.Errorf("Apps.Get returned %+v, want %+v", app, want)
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func TestAppsService_ListInstallations(t *testing.T) {
t.Errorf("Apps.ListInstallations returned error: %v", err)
}

want := []*Installation{{ID: Int(1)}}
want := []*Installation{{ID: Int64(1)}}
if !reflect.DeepEqual(installations, want) {
t.Errorf("Apps.ListInstallations returned %+v, want %+v", installations, want)
}
Expand All @@ -96,7 +96,7 @@ func TestAppsService_GetInstallation(t *testing.T) {
t.Errorf("Apps.GetInstallation returned error: %v", err)
}

want := &Installation{ID: Int(1)}
want := &Installation{ID: Int64(1)}
if !reflect.DeepEqual(installation, want) {
t.Errorf("Apps.GetInstallation returned %+v, want %+v", installation, want)
}
Expand All @@ -122,7 +122,7 @@ func TestAppsService_ListUserInstallations(t *testing.T) {
t.Errorf("Apps.ListUserInstallations returned error: %v", err)
}

want := []*Installation{{ID: Int(1)}}
want := []*Installation{{ID: Int64(1)}}
if !reflect.DeepEqual(installations, want) {
t.Errorf("Apps.ListUserInstallations returned %+v, want %+v", installations, want)
}
Expand Down
Loading

0 comments on commit de3d136

Please sign in to comment.