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

Function TestBindWith

deprecated_test.go:17–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestBindWith(t *testing.T) {
18 w := httptest.NewRecorder()
19 c, _ := CreateTestContext(w)
20
21 c.Request, _ = http.NewRequest(http.MethodPost, "/?foo=bar&bar=foo", bytes.NewBufferString("foo=unused"))
22
23 var obj struct {
24 Foo string `form:"foo"`
25 Bar string `form:"bar"`
26 }
27 captureOutput(t, func() {
28 assert.NoError(t, c.BindWith(&obj, binding.Form))
29 })
30 assert.Equal(t, "foo", obj.Bar)
31 assert.Equal(t, "bar", obj.Foo)
32 assert.Equal(t, 0, w.Body.Len())
33}

Callers

nothing calls this directly

Calls 3

CreateTestContextFunction · 0.85
captureOutputFunction · 0.85
BindWithMethod · 0.80

Tested by

no test coverage detected