Skip to content

Commit

Permalink
Fix pagination resp with "Link" header
Browse files Browse the repository at this point in the history
  • Loading branch information
harveysanders committed Sep 3, 2023
1 parent a454748 commit acc362f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/cmd/run/view/view_test.go
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"net/url"
"testing"
"time"

Expand Down Expand Up @@ -1278,9 +1279,12 @@ func TestViewRun(t *testing.T) {
httpmock.REST("GET", "repos/OWNER/REPO/actions/workflows/123"),
httpmock.JSONResponse(shared.TestWorkflow))
reg.Register(
httpmock.REST("GET", "runs/3/jobs"),
httpmock.JSONResponse(shared.JobsPayload{TotalCount: len(jobs), Jobs: firstPage}))
// /runs/:runID/jobs endpoint should be called once more to fetch the remaining jobs
httpmock.QueryMatcher("GET", "runs/3/jobs", url.Values{"per_page": []string{"100"}}),
httpmock.WithHeader(
httpmock.JSONResponse(shared.JobsPayload{TotalCount: len(jobs), Jobs: firstPage}),
"Link",
`<https://api.github.com/runs/3/jobs?page=2>; rel="next", <https://api.github.com/runs/3/jobs?page=2>; rel="last"`),
)
reg.Register(
httpmock.REST("GET", "runs/3/jobs"),
httpmock.JSONResponse(shared.JobsPayload{TotalCount: len(jobs), Jobs: secondPage}))
Expand Down

0 comments on commit acc362f

Please sign in to comment.