MCPcopy Index your code
hub / github.com/cli/cli / Test_apiRun_paginationREST

Function Test_apiRun_paginationREST

pkg/cmd/api/api_test.go:692–762  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

690}
691
692func Test_apiRun_paginationREST(t *testing.T) {
693 ios, _, stdout, stderr := iostreams.Test()
694
695 requestCount := 0
696 responses := []*http.Response{
697 {
698 Proto: "HTTP/1.1",
699 Status: "200 OK",
700 StatusCode: 200,
701 Body: io.NopCloser(bytes.NewBufferString(`{"page":1}`)),
702 Header: http.Header{
703 "Content-Type": []string{"application/json"},
704 "Link": []string{`<https://api.github.com/repositories/1227/issues?page=2>; rel="next", <https://api.github.com/repositories/1227/issues?page=3>; rel="last"`},
705 "X-Github-Request-Id": []string{"1"},
706 },
707 },
708 {
709 Proto: "HTTP/1.1",
710 Status: "200 OK",
711 StatusCode: 200,
712 Body: io.NopCloser(bytes.NewBufferString(`{"page":2}`)),
713 Header: http.Header{
714 "Content-Type": []string{"application/json"},
715 "Link": []string{`<https://api.github.com/repositories/1227/issues?page=3>; rel="next", <https://api.github.com/repositories/1227/issues?page=3>; rel="last"`},
716 "X-Github-Request-Id": []string{"2"},
717 },
718 },
719 {
720 Proto: "HTTP/1.1",
721 Status: "200 OK",
722 StatusCode: 200,
723 Body: io.NopCloser(bytes.NewBufferString(`{"page":3}`)),
724 Header: http.Header{
725 "Content-Type": []string{"application/json"},
726 "X-Github-Request-Id": []string{"3"},
727 },
728 },
729 }
730
731 options := ApiOptions{
732 IO: ios,
733 HttpClient: func() (*http.Client, error) {
734 var tr roundTripper = func(req *http.Request) (*http.Response, error) {
735 resp := responses[requestCount]
736 resp.Request = req
737 requestCount++
738 return resp, nil
739 }
740 return &http.Client{Transport: tr}, nil
741 },
742 Config: func() (gh.Config, error) {
743 return config.NewBlankConfig(), nil
744 },
745
746 RequestMethod: "GET",
747 RequestMethodPassed: true,
748 RequestPath: "issues",
749 Paginate: true,

Callers

nothing calls this directly

Calls 5

TestFunction · 0.92
NewBlankConfigFunction · 0.92
apiRunFunction · 0.85
EqualMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected