Skip to content

Commit e48060a

Browse files
Kshitij Saraogigmlewis
Kshitij Saraogi
authored andcommitted
Migrate IDs to int64 type (#816)
A helper function "Int64" is also implemented to assist the migration of unit tests. Refer #597.
1 parent b1f1383 commit e48060a

File tree

85 files changed

+444
-440
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+444
-440
lines changed

github/activity_events_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) {
8888
t.Errorf("Activities.ListIssueEventsForRepository returned error: %v", err)
8989
}
9090

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

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

341-
want := &PullRequestEvent{Installation: &Installation{ID: Int(1)}}
341+
want := &PullRequestEvent{Installation: &Installation{ID: Int64(1)}}
342342
got, err := event.ParsePayload()
343343
if err != nil {
344344
t.Fatalf("ParsePayload returned unexpected error: %v", err)

github/activity_star_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestActivityService_ListStargazers(t *testing.T) {
3333
t.Errorf("Activity.ListStargazers returned error: %v", err)
3434
}
3535

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

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

84-
want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int(2)}}}
84+
want := []*StarredRepository{{StarredAt: &Timestamp{time.Date(2002, time.February, 10, 15, 30, 0, 0, time.UTC)}, Repository: &Repository{ID: Int64(2)}}}
8585
if !reflect.DeepEqual(repos, want) {
8686
t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
8787
}

github/activity_watching_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func TestActivityService_ListWatchers(t *testing.T) {
3232
t.Errorf("Activity.ListWatchers returned error: %v", err)
3333
}
3434

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

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

81-
want := []*Repository{{ID: Int(1)}}
81+
want := []*Repository{{ID: Int64(1)}}
8282
if !reflect.DeepEqual(watched, want) {
8383
t.Errorf("Activity.ListWatched returned %+v, want %+v", watched, want)
8484
}

github/admin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type AdminService service
1919

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

3939
// UserLDAPMapping represents the mapping between a GitHub user and an LDAP user.
4040
type UserLDAPMapping struct {
41-
ID *int `json:"id,omitempty"`
41+
ID *int64 `json:"id,omitempty"`
4242
LDAPDN *string `json:"ldap_dn,omitempty"`
4343
Login *string `json:"login,omitempty"`
4444
AvatarURL *string `json:"avatar_url,omitempty"`
@@ -84,7 +84,7 @@ func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, m
8484
// UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group.
8585
//
8686
// GitHub API docs: https://developer.github.com/v3/enterprise/ldap/#update-ldap-mapping-for-a-team
87-
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
87+
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
8888
u := fmt.Sprintf("admin/ldap/teams/%v/mapping", team)
8989
req, err := s.client.NewRequest("PATCH", u, mapping)
9090
if err != nil {

github/admin_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func TestAdminService_UpdateUserLDAPMapping(t *testing.T) {
3939
}
4040

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

7474
want := &TeamLDAPMapping{
75-
ID: Int(1),
75+
ID: Int64(1),
7676
LDAPDN: String("cn=Enterprise Ops,ou=teams,dc=github,dc=com"),
7777
}
7878
if !reflect.DeepEqual(mapping, want) {

github/apps.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type AppsService service
1919

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

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

154154
req, err := s.client.NewRequest("POST", u, nil)

github/apps_installation.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212

1313
// Installation represents a GitHub Apps installation.
1414
type Installation struct {
15-
ID *int `json:"id,omitempty"`
15+
ID *int64 `json:"id,omitempty"`
1616
Account *User `json:"account,omitempty"`
1717
AccessTokensURL *string `json:"access_tokens_url,omitempty"`
1818
RepositoriesURL *string `json:"repositories_url,omitempty"`
@@ -55,7 +55,7 @@ func (s *AppsService) ListRepos(ctx context.Context, opt *ListOptions) ([]*Repos
5555
// to the authenticated user for an installation.
5656
//
5757
// GitHub API docs: https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation
58-
func (s *AppsService) ListUserRepos(ctx context.Context, id int, opt *ListOptions) ([]*Repository, *Response, error) {
58+
func (s *AppsService) ListUserRepos(ctx context.Context, id int64, opt *ListOptions) ([]*Repository, *Response, error) {
5959
u := fmt.Sprintf("user/installations/%v/repositories", id)
6060
u, err := addOptions(u, opt)
6161
if err != nil {
@@ -84,7 +84,7 @@ func (s *AppsService) ListUserRepos(ctx context.Context, id int, opt *ListOption
8484
// AddRepository adds a single repository to an installation.
8585
//
8686
// GitHub API docs: https://developer.github.com/v3/apps/installations/#add-repository-to-installation
87-
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int) (*Repository, *Response, error) {
87+
func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int64) (*Repository, *Response, error) {
8888
u := fmt.Sprintf("apps/installations/%v/repositories/%v", instID, repoID)
8989
req, err := s.client.NewRequest("PUT", u, nil)
9090
if err != nil {
@@ -103,7 +103,7 @@ func (s *AppsService) AddRepository(ctx context.Context, instID, repoID int) (*R
103103
// RemoveRepository removes a single repository from an installation.
104104
//
105105
// GitHub docs: https://developer.github.com/v3/apps/installations/#remove-repository-from-installation
106-
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int) (*Response, error) {
106+
func (s *AppsService) RemoveRepository(ctx context.Context, instID, repoID int64) (*Response, error) {
107107
u := fmt.Sprintf("apps/installations/%v/repositories/%v", instID, repoID)
108108
req, err := s.client.NewRequest("DELETE", u, nil)
109109
if err != nil {

github/apps_installation_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestAppsService_ListRepos(t *testing.T) {
3333
t.Errorf("Apps.ListRepos returned error: %v", err)
3434
}
3535

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

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

82-
want := &Repository{ID: Int(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}}
82+
want := &Repository{ID: Int64(1), Name: String("n"), Description: String("d"), Owner: &User{Login: String("l")}, License: &License{Key: String("mit")}}
8383
if !reflect.DeepEqual(repo, want) {
8484
t.Errorf("AddRepository returned %+v, want %+v", repo, want)
8585
}

github/apps_marketplace.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ type MarketplaceService struct {
2929
type MarketplacePlan struct {
3030
URL *string `json:"url,omitempty"`
3131
AccountsURL *string `json:"accounts_url,omitempty"`
32-
ID *int `json:"id,omitempty"`
32+
ID *int64 `json:"id,omitempty"`
3333
Name *string `json:"name,omitempty"`
3434
Description *string `json:"description,omitempty"`
3535
MonthlyPriceInCents *int `json:"monthly_price_in_cents,omitempty"`
@@ -52,7 +52,7 @@ type MarketplacePurchase struct {
5252
type MarketplacePlanAccount struct {
5353
URL *string `json:"url,omitempty"`
5454
Type *string `json:"type,omitempty"`
55-
ID *int `json:"id,omitempty"`
55+
ID *int64 `json:"id,omitempty"`
5656
Login *string `json:"login,omitempty"`
5757
Email *string `json:"email,omitempty"`
5858
OrganizationBillingEmail *string `json:"organization_billing_email,omitempty"`
@@ -89,7 +89,7 @@ func (s *MarketplaceService) ListPlans(ctx context.Context, opt *ListOptions) ([
8989
// ListPlanAccountsForPlan lists all GitHub accounts (user or organization) on a specific plan.
9090
//
9191
// GitHub API docs: https://developer.github.com/v3/apps/marketplace/#list-all-github-accounts-user-or-organization-on-a-specific-plan
92-
func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int, opt *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
92+
func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID int64, opt *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
9393
uri := s.marketplaceURI(fmt.Sprintf("plans/%v/accounts", planID))
9494
u, err := addOptions(uri, opt)
9595
if err != nil {
@@ -116,7 +116,7 @@ func (s *MarketplaceService) ListPlanAccountsForPlan(ctx context.Context, planID
116116
// ListPlanAccountsForAccount lists all GitHub accounts (user or organization) associated with an account.
117117
//
118118
// GitHub API docs: https://developer.github.com/v3/apps/marketplace/#check-if-a-github-account-is-associated-with-any-marketplace-listing
119-
func (s *MarketplaceService) ListPlanAccountsForAccount(ctx context.Context, accountID int, opt *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
119+
func (s *MarketplaceService) ListPlanAccountsForAccount(ctx context.Context, accountID int64, opt *ListOptions) ([]*MarketplacePlanAccount, *Response, error) {
120120
uri := s.marketplaceURI(fmt.Sprintf("accounts/%v", accountID))
121121
u, err := addOptions(uri, opt)
122122
if err != nil {

github/apps_marketplace_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestMarketplaceService_ListPlans(t *testing.T) {
3434
t.Errorf("Marketplace.ListPlans returned error: %v", err)
3535
}
3636

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

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

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

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

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

152-
want := []*MarketplacePlanAccount{{ID: Int(1)}}
152+
want := []*MarketplacePlanAccount{{ID: Int64(1)}}
153153
if !reflect.DeepEqual(accounts, want) {
154154
t.Errorf("Marketplace.ListPlanAccountsForAccount (Stubbed) returned %+v, want %+v", accounts, want)
155155
}

github/apps_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestAppsService_Get_authenticatedApp(t *testing.T) {
2828
t.Errorf("Apps.Get returned error: %v", err)
2929
}
3030

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

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

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

125-
want := []*Installation{{ID: Int(1)}}
125+
want := []*Installation{{ID: Int64(1)}}
126126
if !reflect.DeepEqual(installations, want) {
127127
t.Errorf("Apps.ListUserInstallations returned %+v, want %+v", installations, want)
128128
}

0 commit comments

Comments
 (0)