Home / Function/ testBodyBindingStringMap() — gin Function Reference

testBodyBindingStringMap() — gin Function Reference

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

Function go RequestBinding FormBinding calls 1 called by 3

Entity Profile

Dependency Diagram

graph TD
  4ac109c1_2e51_117f_abf6_be59540f3c03["testBodyBindingStringMap()"]
  314c6481_2bd0_e5a7_282c_94e41df6062a["binding_test.go"]
  4ac109c1_2e51_117f_abf6_be59540f3c03 -->|defined in| 314c6481_2bd0_e5a7_282c_94e41df6062a
  738090a2_9aae_e0ac_a945_b43b3e701bd2["TestBindingJSONStringMap()"]
  738090a2_9aae_e0ac_a945_b43b3e701bd2 -->|calls| 4ac109c1_2e51_117f_abf6_be59540f3c03
  e3612572_6c53_5f9e_0f3a_3398f76d22ef["TestBindingFormStringMap()"]
  e3612572_6c53_5f9e_0f3a_3398f76d22ef -->|calls| 4ac109c1_2e51_117f_abf6_be59540f3c03
  12694ac2_d892_8c2f_f5fa_9f0f9d731d55["TestBindingYAMLStringMap()"]
  12694ac2_d892_8c2f_f5fa_9f0f9d731d55 -->|calls| 4ac109c1_2e51_117f_abf6_be59540f3c03
  aebd0564_565b_ba1b_7f92_4baaca0e7b7e["requestWithBody()"]
  4ac109c1_2e51_117f_abf6_be59540f3c03 -->|calls| aebd0564_565b_ba1b_7f92_4baaca0e7b7e
  style 4ac109c1_2e51_117f_abf6_be59540f3c03 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binding/binding_test.go lines 1246–1270

func testBodyBindingStringMap(t *testing.T, b Binding, path, badPath, body, badBody string) {
	obj := make(map[string]string)
	req := requestWithBody(http.MethodPost, path, body)
	if b.Name() == "form" {
		req.Header.Add("Content-Type", MIMEPOSTForm)
	}
	err := b.Bind(req, &obj)
	require.NoError(t, err)
	assert.NotNil(t, obj)
	assert.Len(t, obj, 2)
	assert.Equal(t, "bar", obj["foo"])
	assert.Equal(t, "world", obj["hello"])

	if badPath != "" && badBody != "" {
		obj = make(map[string]string)
		req = requestWithBody(http.MethodPost, badPath, badBody)
		err = b.Bind(req, &obj)
		require.Error(t, err)
	}

	objInt := make(map[string]int)
	req = requestWithBody(http.MethodPost, path, body)
	err = b.Bind(req, &objInt)
	require.Error(t, err)
}

Subdomains

Frequently Asked Questions

What does testBodyBindingStringMap() do?
testBodyBindingStringMap() is a function in the gin codebase, defined in binding/binding_test.go.
Where is testBodyBindingStringMap() defined?
testBodyBindingStringMap() is defined in binding/binding_test.go at line 1246.
What does testBodyBindingStringMap() call?
testBodyBindingStringMap() calls 1 function(s): requestWithBody.
What calls testBodyBindingStringMap()?
testBodyBindingStringMap() is called by 3 function(s): TestBindingFormStringMap, TestBindingJSONStringMap, TestBindingYAMLStringMap.

Analyze Your Own Codebase

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

Try Supermodel Free