Skip to content

Commit

Permalink
Fix #2416 Pagination for list user migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
amitsaha committed Aug 22, 2022
1 parent 01c8feb commit 782ffc0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion github/migrations_user.go
Expand Up @@ -97,8 +97,12 @@ func (s *MigrationService) StartUserMigration(ctx context.Context, repos []strin
// ListUserMigrations lists the most recent migrations.
//
// GitHub API docs: https://docs.github.com/en/rest/migrations/users#list-user-migrations
func (s *MigrationService) ListUserMigrations(ctx context.Context) ([]*UserMigration, *Response, error) {
func (s *MigrationService) ListUserMigrations(ctx context.Context, opts *ListOptions) ([]*UserMigration, *Response, error) {
u := "user/migrations"
u, err := addOptions(u, opts)
if err != nil {
return nil, nil, err
}

req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions github/migrations_user_test.go
Expand Up @@ -66,7 +66,7 @@ func TestMigrationService_ListUserMigrations(t *testing.T) {
})

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

const methodName = "ListUserMigrations"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Migrations.ListUserMigrations(ctx)
got, resp, err := client.Migrations.ListUserMigrations(ctx, &ListOptions{Page: 1, PerPage: 2})
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
Expand Down

0 comments on commit 782ffc0

Please sign in to comment.