MCPcopy Create free account
hub / github.com/fsouza/go-dockerclient / TestQueryString

Function TestQueryString

client_test.go:367–409  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

365}
366
367func TestQueryString(t *testing.T) {
368 t.Parallel()
369 v := float32(2.4)
370 f32QueryString := fmt.Sprintf("w=%s&x=10&y=10.35", strconv.FormatFloat(float64(v), 'f', -1, 64))
371 jsonPerson := url.QueryEscape(`{"Name":"gopher","age":4}`)
372 tests := []struct {
373 input any
374 want string
375 wantAPI APIVersion
376 }{
377 {&ListContainersOptions{All: true}, "all=1", nil},
378 {ListContainersOptions{All: true}, "all=1", nil},
379 {ListContainersOptions{Before: "something"}, "before=something", nil},
380 {ListContainersOptions{Before: "something", Since: "other"}, "before=something&since=other", nil},
381 {ListContainersOptions{Filters: map[string][]string{"status": {"paused", "running"}}}, "filters=%7B%22status%22%3A%5B%22paused%22%2C%22running%22%5D%7D", nil},
382 {dumb{X: 10, Y: 10.35000}, "x=10&y=10.35", apiVersion119},
383 {dumb{W: v, X: 10, Y: 10.35000}, f32QueryString, apiVersion124},
384 {dumb{X: 10, Y: 10.35000, Z: 10}, "x=10&y=10.35&zee=10", apiVersion119},
385 {dumb{v: 4, X: 10, Y: 10.35000}, "x=10&y=10.35", apiVersion119},
386 {dumb{T: 10, Y: 10.35000}, "y=10.35", nil},
387 {dumb{Person: &person{Name: "gopher", Age: 4}}, "p=" + jsonPerson, nil},
388 {nil, "", nil},
389 {10, "", nil},
390 {"not_a_struct", "", nil},
391 }
392 for _, tt := range tests {
393 test := tt
394 t.Run("", func(t *testing.T) {
395 t.Parallel()
396 got := queryString(test.input)
397 if got != test.want {
398 t.Errorf("queryString(%v). Want %q. Got %q.", test.input, test.want, got)
399 }
400 gotstring, gotAPI := queryStringVersion(test.input)
401 if gotstring != test.want {
402 t.Errorf("queryStringVersion(%v). Want %q. Got %q.", test.input, test.want, gotstring)
403 }
404 if gotAPI.compare(test.wantAPI) != 0 {
405 t.Errorf("queryStringVersion(%v). Want API %q. Got API %q.", test.input, test.wantAPI, gotAPI)
406 }
407 })
408 }
409}
410
411func TestAPIVersions(t *testing.T) {
412 t.Parallel()

Callers

nothing calls this directly

Calls 3

queryStringFunction · 0.85
queryStringVersionFunction · 0.85
compareMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…