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

Function TestContextBindWithQuery

context_test.go:2238–2252  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2236}
2237
2238func TestContextBindWithQuery(t *testing.T) {
2239 w := httptest.NewRecorder()
2240 c, _ := CreateTestContext(w)
2241
2242 c.Request, _ = http.NewRequest(http.MethodPost, "/?foo=bar&bar=foo", strings.NewReader("foo=unused"))
2243
2244 var obj struct {
2245 Foo string `form:"foo"`
2246 Bar string `form:"bar"`
2247 }
2248 require.NoError(t, c.BindQuery(&obj))
2249 assert.Equal(t, "foo", obj.Bar)
2250 assert.Equal(t, "bar", obj.Foo)
2251 assert.Equal(t, 0, w.Body.Len())
2252}
2253
2254func TestContextBindWithYAML(t *testing.T) {
2255 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 2

CreateTestContextFunction · 0.85
BindQueryMethod · 0.80

Tested by

no test coverage detected