alwaysHasNextPageLabelsClient returns a GraphQL client whose labels query always reports another page, advancing the cursor on each call. It exercises uiGetLabels' page cap: the loop fetches one label per page until it stops at uiGetMaxPages with has_more=true. totalCount is reported as a large serv
(t *testing.T)
| 39 | // has_more=true. totalCount is reported as a large server-side count so the test can |
| 40 | // confirm it stays the full repo count even when results are truncated. |
| 41 | func alwaysHasNextPageLabelsClient(t *testing.T) *http.Client { |
| 42 | t.Helper() |
| 43 | var calls int |
| 44 | mux := http.NewServeMux() |
| 45 | mux.HandleFunc("/graphql", func(w http.ResponseWriter, _ *http.Request) { |
| 46 | calls++ |
| 47 | resp := map[string]any{ |
| 48 | "data": map[string]any{ |
| 49 | "repository": map[string]any{ |
| 50 | "labels": map[string]any{ |
| 51 | "nodes": []any{ |
| 52 | map[string]any{ |
| 53 | "id": fmt.Sprintf("label-%d", calls), |
| 54 | "name": fmt.Sprintf("label-%d", calls), |
| 55 | "color": "ededed", |
| 56 | "description": "", |
| 57 | }, |
| 58 | }, |
| 59 | "totalCount": 9999, |
| 60 | "pageInfo": map[string]any{ |
| 61 | "hasNextPage": true, |
| 62 | "endCursor": fmt.Sprintf("cursor-%d", calls), |
| 63 | }, |
| 64 | }, |
| 65 | }, |
| 66 | }, |
| 67 | } |
| 68 | w.Header().Set("Content-Type", "application/json") |
| 69 | _ = json.NewEncoder(w).Encode(resp) |
| 70 | }) |
| 71 | return &http.Client{Transport: recorderTransport{handler: mux}} |
| 72 | } |
| 73 | |
| 74 | // alwaysNextPageHandler returns a REST handler that always advertises another page |
| 75 | // via the Link header, regardless of the page requested. It drives a pagination loop |