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

Function TestContextBindWithYAML

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

Source from the content-addressed store, hash-verified

2252}
2253
2254func TestContextBindWithYAML(t *testing.T) {
2255 w := httptest.NewRecorder()
2256 c, _ := CreateTestContext(w)
2257
2258 c.Request, _ = http.NewRequest(http.MethodPost, "/", strings.NewReader("foo: bar\nbar: foo"))
2259 c.Request.Header.Add("Content-Type", MIMEXML) // set fake content-type
2260
2261 var obj struct {
2262 Foo string `yaml:"foo"`
2263 Bar string `yaml:"bar"`
2264 }
2265 require.NoError(t, c.BindYAML(&obj))
2266 assert.Equal(t, "foo", obj.Bar)
2267 assert.Equal(t, "bar", obj.Foo)
2268 assert.Equal(t, 0, w.Body.Len())
2269}
2270
2271func TestContextBindWithTOML(t *testing.T) {
2272 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 2

CreateTestContextFunction · 0.85
BindYAMLMethod · 0.80

Tested by

no test coverage detected