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

Function testFormBinding

binding/binding_test.go:874–892  ·  view source on GitHub ↗
(t *testing.T, method, path, badPath, body, badBody string)

Source from the content-addressed store, hash-verified

872}
873
874func testFormBinding(t *testing.T, method, path, badPath, body, badBody string) {
875 b := Form
876 assert.Equal(t, "form", b.Name())
877
878 obj := FooBarStruct{}
879 req := requestWithBody(method, path, body)
880 if method == http.MethodPost {
881 req.Header.Add("Content-Type", MIMEPOSTForm)
882 }
883 err := b.Bind(req, &obj)
884 require.NoError(t, err)
885 assert.Equal(t, "bar", obj.Foo)
886 assert.Equal(t, "foo", obj.Bar)
887
888 obj = FooBarStruct{}
889 req = requestWithBody(method, badPath, badBody)
890 err = JSON.Bind(req, &obj)
891 require.Error(t, err)
892}
893
894func testFormBindingDefaultValue(t *testing.T, method, path, badPath, body, badBody string) {
895 b := Form

Callers 2

TestBindingFormFunction · 0.85
TestBindingForm2Function · 0.85

Calls 4

requestWithBodyFunction · 0.85
NameMethod · 0.65
BindMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected