(t *testing.T)
| 1019 | } |
| 1020 | |
| 1021 | func Test_apiRun_paginationGraphQL(t *testing.T) { |
| 1022 | ios, _, stdout, stderr := iostreams.Test() |
| 1023 | |
| 1024 | requestCount := 0 |
| 1025 | responses := []*http.Response{ |
| 1026 | { |
| 1027 | StatusCode: 200, |
| 1028 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1029 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1030 | { |
| 1031 | "data": { |
| 1032 | "nodes": ["page one"], |
| 1033 | "pageInfo": { |
| 1034 | "endCursor": "PAGE1_END", |
| 1035 | "hasNextPage": true |
| 1036 | } |
| 1037 | } |
| 1038 | }`))), |
| 1039 | }, |
| 1040 | { |
| 1041 | StatusCode: 200, |
| 1042 | Header: http.Header{"Content-Type": []string{`application/json`}}, |
| 1043 | Body: io.NopCloser(bytes.NewBufferString(heredoc.Doc(` |
| 1044 | { |
| 1045 | "data": { |
| 1046 | "nodes": ["page two"], |
| 1047 | "pageInfo": { |
| 1048 | "endCursor": "PAGE2_END", |
| 1049 | "hasNextPage": false |
| 1050 | } |
| 1051 | } |
| 1052 | }`))), |
| 1053 | }, |
| 1054 | } |
| 1055 | |
| 1056 | options := ApiOptions{ |
| 1057 | IO: ios, |
| 1058 | HttpClient: func(rootapi.HTTPClientOptions) (*http.Client, error) { |
| 1059 | var tr roundTripper = func(req *http.Request) (*http.Response, error) { |
| 1060 | resp := responses[requestCount] |
| 1061 | resp.Request = req |
| 1062 | requestCount++ |
| 1063 | return resp, nil |
| 1064 | } |
| 1065 | return &http.Client{Transport: tr}, nil |
| 1066 | }, |
| 1067 | Config: func() (gh.Config, error) { |
| 1068 | return config.NewMockConfig(), nil |
| 1069 | }, |
| 1070 | |
| 1071 | RawFields: []string{"foo=bar"}, |
| 1072 | RequestMethod: "POST", |
| 1073 | RequestPath: "graphql", |
| 1074 | Paginate: true, |
| 1075 | } |
| 1076 | |
| 1077 | err := apiRun(&options) |
| 1078 | require.NoError(t, err) |
nothing calls this directly
no test coverage detected