Home / Function/ testBodyBindingDisallowUnknownFields() — gin Function Reference

testBodyBindingDisallowUnknownFields() — gin Function Reference

Architecture documentation for the testBodyBindingDisallowUnknownFields() function in binding_test.go from the gin codebase.

Function go RequestBinding FormBinding calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  ff095243_b96f_e338_0894_1a118ff83a0a["testBodyBindingDisallowUnknownFields()"]
  314c6481_2bd0_e5a7_282c_94e41df6062a["binding_test.go"]
  ff095243_b96f_e338_0894_1a118ff83a0a -->|defined in| 314c6481_2bd0_e5a7_282c_94e41df6062a
  6c04c3c9_7e00_5d2a_1665_5366e9893725["TestBindingJSONDisallowUnknownFields()"]
  6c04c3c9_7e00_5d2a_1665_5366e9893725 -->|calls| ff095243_b96f_e338_0894_1a118ff83a0a
  aebd0564_565b_ba1b_7f92_4baaca0e7b7e["requestWithBody()"]
  ff095243_b96f_e338_0894_1a118ff83a0a -->|calls| aebd0564_565b_ba1b_7f92_4baaca0e7b7e
  style ff095243_b96f_e338_0894_1a118ff83a0a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binding/binding_test.go lines 1309–1326

func testBodyBindingDisallowUnknownFields(t *testing.T, b Binding, path, badPath, body, badBody string) {
	EnableDecoderDisallowUnknownFields = true
	defer func() {
		EnableDecoderDisallowUnknownFields = false
	}()

	obj := FooStructDisallowUnknownFields{}
	req := requestWithBody(http.MethodPost, path, body)
	err := b.Bind(req, &obj)
	require.NoError(t, err)
	assert.Equal(t, "bar", obj.Foo)

	obj = FooStructDisallowUnknownFields{}
	req = requestWithBody(http.MethodPost, badPath, badBody)
	err = JSON.Bind(req, &obj)
	require.Error(t, err)
	assert.Contains(t, err.Error(), "what")
}

Subdomains

Frequently Asked Questions

What does testBodyBindingDisallowUnknownFields() do?
testBodyBindingDisallowUnknownFields() is a function in the gin codebase, defined in binding/binding_test.go.
Where is testBodyBindingDisallowUnknownFields() defined?
testBodyBindingDisallowUnknownFields() is defined in binding/binding_test.go at line 1309.
What does testBodyBindingDisallowUnknownFields() call?
testBodyBindingDisallowUnknownFields() calls 1 function(s): requestWithBody.
What calls testBodyBindingDisallowUnknownFields()?
testBodyBindingDisallowUnknownFields() is called by 1 function(s): TestBindingJSONDisallowUnknownFields.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free