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

Function Test_addPerPage

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

Source from the content-addressed store, hash-verified

121}
122
123func Test_addPerPage(t *testing.T) {
124 type args struct {
125 p string
126 perPage int
127 params map[string]interface{}
128 }
129 tests := []struct {
130 name string
131 args args
132 want string
133 }{
134 {
135 name: "adds per_page",
136 args: args{
137 p: "items",
138 perPage: 13,
139 params: nil,
140 },
141 want: "items?per_page=13",
142 },
143 {
144 name: "avoids adding per_page if already in params",
145 args: args{
146 p: "items",
147 perPage: 13,
148 params: map[string]interface{}{
149 "state": "open",
150 "per_page": 99,
151 },
152 },
153 want: "items",
154 },
155 {
156 name: "avoids adding per_page if already in query",
157 args: args{
158 p: "items?per_page=6&state=open",
159 perPage: 13,
160 params: nil,
161 },
162 want: "items?per_page=6&state=open",
163 },
164 }
165 for _, tt := range tests {
166 t.Run(tt.name, func(t *testing.T) {
167 if got := addPerPage(tt.args.p, tt.args.perPage, tt.args.params); got != tt.want {
168 t.Errorf("addPerPage() = %v, want %v", got, tt.want)
169 }
170 })
171 }
172}
173
174func TestJsonArrayWriter(t *testing.T) {
175 tests := []struct {

Callers

nothing calls this directly

Calls 3

addPerPageFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected