MCPcopy
hub / github.com/gin-gonic/gin / TestBindingQueryStringMap

Function TestBindingQueryStringMap

binding/binding_test.go:432–452  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

430}
431
432func TestBindingQueryStringMap(t *testing.T) {
433 b := Query
434
435 obj := make(map[string]string)
436 req := requestWithBody(http.MethodGet, "/?foo=bar&hello=world", "")
437 err := b.Bind(req, &obj)
438 require.NoError(t, err)
439 assert.NotNil(t, obj)
440 assert.Len(t, obj, 2)
441 assert.Equal(t, "bar", obj["foo"])
442 assert.Equal(t, "world", obj["hello"])
443
444 obj = make(map[string]string)
445 req = requestWithBody(http.MethodGet, "/?foo=bar&foo=2&hello=world", "") // should pick last
446 err = b.Bind(req, &obj)
447 require.NoError(t, err)
448 assert.NotNil(t, obj)
449 assert.Len(t, obj, 2)
450 assert.Equal(t, "2", obj["foo"])
451 assert.Equal(t, "world", obj["hello"])
452}
453
454func TestBindingXML(t *testing.T) {
455 testBodyBinding(t,

Callers

nothing calls this directly

Calls 2

requestWithBodyFunction · 0.85
BindMethod · 0.65

Tested by

no test coverage detected