MCPcopy
hub / github.com/cli/cli / Test_addQuery

Function Test_addQuery

pkg/cmd/api/http_test.go:343–425  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

341}
342
343func Test_addQuery(t *testing.T) {
344 type args struct {
345 path string
346 params map[string]interface{}
347 }
348 tests := []struct {
349 name string
350 args args
351 want string
352 }{
353 {
354 name: "string",
355 args: args{
356 path: "",
357 params: map[string]interface{}{"a": "hello"},
358 },
359 want: "?a=hello",
360 },
361 {
362 name: "array",
363 args: args{
364 path: "",
365 params: map[string]interface{}{"a": []interface{}{"hello", "world"}},
366 },
367 want: "?a%5B%5D=hello&a%5B%5D=world",
368 },
369 {
370 name: "append",
371 args: args{
372 path: "path",
373 params: map[string]interface{}{"a": "b"},
374 },
375 want: "path?a=b",
376 },
377 {
378 name: "append query",
379 args: args{
380 path: "path?foo=bar",
381 params: map[string]interface{}{"a": "b"},
382 },
383 want: "path?foo=bar&a=b",
384 },
385 {
386 name: "[]byte",
387 args: args{
388 path: "",
389 params: map[string]interface{}{"a": []byte("hello")},
390 },
391 want: "?a=hello",
392 },
393 {
394 name: "int",
395 args: args{
396 path: "",
397 params: map[string]interface{}{"a": 123},
398 },
399 want: "?a=123",
400 },

Callers

nothing calls this directly

Calls 3

addQueryFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected