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

Function Test_addQuery

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

Source from the content-addressed store, hash-verified

462}
463
464func Test_addQuery(t *testing.T) {
465 type args struct {
466 path string
467 params map[string]any
468 }
469 tests := []struct {
470 name string
471 args args
472 want string
473 }{
474 {
475 name: "string",
476 args: args{
477 path: "",
478 params: map[string]any{"a": "hello"},
479 },
480 want: "?a=hello",
481 },
482 {
483 name: "array",
484 args: args{
485 path: "",
486 params: map[string]any{"a": []any{"hello", "world"}},
487 },
488 want: "?a%5B%5D=hello&a%5B%5D=world",
489 },
490 {
491 name: "append",
492 args: args{
493 path: "path",
494 params: map[string]any{"a": "b"},
495 },
496 want: "path?a=b",
497 },
498 {
499 name: "append query",
500 args: args{
501 path: "path?foo=bar",
502 params: map[string]any{"a": "b"},
503 },
504 want: "path?foo=bar&a=b",
505 },
506 {
507 name: "[]byte",
508 args: args{
509 path: "",
510 params: map[string]any{"a": []byte("hello")},
511 },
512 want: "?a=hello",
513 },
514 {
515 name: "int",
516 args: args{
517 path: "",
518 params: map[string]any{"a": 123},
519 },
520 want: "?a=123",
521 },

Callers

nothing calls this directly

Calls 3

addQueryFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected