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

Function Test_findEndCursor

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

Source from the content-addressed store, hash-verified

58}
59
60func Test_findEndCursor(t *testing.T) {
61 tests := []struct {
62 name string
63 json io.Reader
64 want string
65 }{
66 {
67 name: "blank",
68 json: bytes.NewBufferString(`{}`),
69 want: "",
70 },
71 {
72 name: "unrelated fields",
73 json: bytes.NewBufferString(`{
74 "hasNextPage": true,
75 "endCursor": "THE_END"
76 }`),
77 want: "",
78 },
79 {
80 name: "has next page",
81 json: bytes.NewBufferString(`{
82 "pageInfo": {
83 "hasNextPage": true,
84 "endCursor": "THE_END"
85 }
86 }`),
87 want: "THE_END",
88 },
89 {
90 name: "more pageInfo blocks",
91 json: bytes.NewBufferString(`{
92 "pageInfo": {
93 "hasNextPage": true,
94 "endCursor": "THE_END"
95 },
96 "pageInfo": {
97 "hasNextPage": true,
98 "endCursor": "NOT_THIS"
99 }
100 }`),
101 want: "THE_END",
102 },
103 {
104 name: "no next page",
105 json: bytes.NewBufferString(`{
106 "pageInfo": {
107 "hasNextPage": false,
108 "endCursor": "THE_END"
109 }
110 }`),
111 want: "",
112 },
113 }
114 for _, tt := range tests {
115 t.Run(tt.name, func(t *testing.T) {
116 if got := findEndCursor(tt.json); got != tt.want {
117 t.Errorf("findEndCursor() = %v, want %v", got, tt.want)

Callers

nothing calls this directly

Calls 3

findEndCursorFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected