Skip to content

Commit

Permalink
Simplify mock jobs response
Browse files Browse the repository at this point in the history
  • Loading branch information
harveysanders committed Sep 4, 2023
1 parent d5d10a6 commit 137da73
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions pkg/cmd/run/view/view_test.go
Expand Up @@ -1260,18 +1260,6 @@ func TestViewRun(t *testing.T) {
),
},
httpStubs: func(reg *httpmock.Registry) {
jobs := []shared.Job{}
for i := 0; i < 115; i++ {
jobs = append(jobs, shared.Job{
ID: int64(i),
Name: fmt.Sprintf("job %d", i),
})
}

limit := 100
firstPage := jobs[:limit]
secondPage := jobs[limit:]

reg.Register(
httpmock.REST("GET", "repos/OWNER/REPO/actions/runs/3"),
httpmock.JSONResponse(shared.SuccessfulRun))
Expand All @@ -1281,15 +1269,15 @@ func TestViewRun(t *testing.T) {
reg.Register(
httpmock.QueryMatcher("GET", "runs/3/jobs", url.Values{"per_page": []string{"100"}}),
httpmock.WithHeader(
httpmock.JSONResponse(shared.JobsPayload{TotalCount: len(jobs), Jobs: firstPage}),
httpmock.StringResponse(`{"jobs":[{},{},{}]}`),
"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}))
httpmock.StringResponse(`{"jobs":[{},{}]}`))
},
wantOut: "fetched 115 jobs\n",
wantOut: "fetched 5 jobs\n",
},
}

Expand Down

0 comments on commit 137da73

Please sign in to comment.