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 DataBinding Mappers calls 1 called by 3

Entity Profile

Dependency Diagram

graph TD
  9c404a09_5549_29ea_273c_de24c51eb96b["testBodyBindingStringMap()"]
  59670d9e_cda8_6077_a4d9_d4ca901b4796["TestBindingJSONStringMap()"]
  59670d9e_cda8_6077_a4d9_d4ca901b4796 -->|calls| 9c404a09_5549_29ea_273c_de24c51eb96b
  33399b39_3217_3baa_6742_501d8786b5ad["TestBindingFormStringMap()"]
  33399b39_3217_3baa_6742_501d8786b5ad -->|calls| 9c404a09_5549_29ea_273c_de24c51eb96b
  149e318c_cdb2_af6e_413f_3843222ed45d["TestBindingYAMLStringMap()"]
  149e318c_cdb2_af6e_413f_3843222ed45d -->|calls| 9c404a09_5549_29ea_273c_de24c51eb96b
  2899e942_a23d_574e_8d47_d28e895c2604["requestWithBody()"]
  9c404a09_5549_29ea_273c_de24c51eb96b -->|calls| 2899e942_a23d_574e_8d47_d28e895c2604
  style 9c404a09_5549_29ea_273c_de24c51eb96b 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)
}

Domain

Subdomains

Frequently Asked Questions

What does testBodyBindingStringMap() do?
testBodyBindingStringMap() is a function in the gin codebase.
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