Skip to content

Commit dd22b73

Browse files
authored
Add ListOptions for listing user migrations (#2417)
Fixes: #2416.
1 parent 01c8feb commit dd22b73

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

example/migrations/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func fetchAllUserMigrations() ([]*github.UserMigration, error) {
2424
tc := oauth2.NewClient(ctx, ts)
2525
client := github.NewClient(tc)
2626

27-
migrations, _, err := client.Migrations.ListUserMigrations(ctx)
27+
migrations, _, err := client.Migrations.ListUserMigrations(ctx, &github.ListOptions{Page: 1})
2828
return migrations, err
2929
}
3030

github/migrations_user.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ func (s *MigrationService) StartUserMigration(ctx context.Context, repos []strin
9797
// ListUserMigrations lists the most recent migrations.
9898
//
9999
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#list-user-migrations
100-
func (s *MigrationService) ListUserMigrations(ctx context.Context) ([]*UserMigration, *Response, error) {
100+
func (s *MigrationService) ListUserMigrations(ctx context.Context, opts *ListOptions) ([]*UserMigration, *Response, error) {
101101
u := "user/migrations"
102+
u, err := addOptions(u, opts)
103+
if err != nil {
104+
return nil, nil, err
105+
}
102106

103107
req, err := s.client.NewRequest("GET", u, nil)
104108
if err != nil {

github/migrations_user_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestMigrationService_ListUserMigrations(t *testing.T) {
6666
})
6767

6868
ctx := context.Background()
69-
got, _, err := client.Migrations.ListUserMigrations(ctx)
69+
got, _, err := client.Migrations.ListUserMigrations(ctx, &ListOptions{Page: 1, PerPage: 2})
7070
if err != nil {
7171
t.Errorf("ListUserMigrations returned error %v", err)
7272
}
@@ -78,7 +78,7 @@ func TestMigrationService_ListUserMigrations(t *testing.T) {
7878

7979
const methodName = "ListUserMigrations"
8080
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
81-
got, resp, err := client.Migrations.ListUserMigrations(ctx)
81+
got, resp, err := client.Migrations.ListUserMigrations(ctx, &ListOptions{Page: 1, PerPage: 2})
8282
if got != nil {
8383
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
8484
}

0 commit comments

Comments
 (0)