MCPcopy Create free account
hub / github.com/cli/cli / Test_findNextPage

Function Test_findNextPage

pkg/cmd/api/pagination_test.go:13–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11)
12
13func Test_findNextPage(t *testing.T) {
14 tests := []struct {
15 name string
16 resp *http.Response
17 want string
18 want1 bool
19 }{
20 {
21 name: "no Link header",
22 resp: &http.Response{},
23 want: "",
24 want1: false,
25 },
26 {
27 name: "no next page in Link",
28 resp: &http.Response{
29 Header: http.Header{
30 "Link": []string{`<https://api.github.com/issues?page=3>; rel="last"`},
31 },
32 },
33 want: "",
34 want1: false,
35 },
36 {
37 name: "has next page",
38 resp: &http.Response{
39 Header: http.Header{
40 "Link": []string{`<https://api.github.com/issues?page=2>; rel="next", <https://api.github.com/issues?page=3>; rel="last"`},
41 },
42 },
43 want: "https://api.github.com/issues?page=2",
44 want1: true,
45 },
46 }
47 for _, tt := range tests {
48 t.Run(tt.name, func(t *testing.T) {
49 got, got1 := findNextPage(tt.resp)
50 if got != tt.want {
51 t.Errorf("findNextPage() got = %v, want %v", got, tt.want)
52 }
53 if got1 != tt.want1 {
54 t.Errorf("findNextPage() got1 = %v, want %v", got1, tt.want1)
55 }
56 })
57 }
58}
59
60func Test_findEndCursor(t *testing.T) {
61 tests := []struct {

Callers

nothing calls this directly

Calls 3

findNextPageFunction · 0.70
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected