Home / Function/ testProtoBodyBindingFail() — gin Function Reference

testProtoBodyBindingFail() — gin Function Reference

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

Function go DataBinding Mappers calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  52171b08_09ce_e66b_ae2b_698aed2b7131["testProtoBodyBindingFail()"]
  6b3dc2ac_b948_6f09_6796_a3485d15f50e["TestBindingProtoBufFail()"]
  6b3dc2ac_b948_6f09_6796_a3485d15f50e -->|calls| 52171b08_09ce_e66b_ae2b_698aed2b7131
  2899e942_a23d_574e_8d47_d28e895c2604["requestWithBody()"]
  52171b08_09ce_e66b_ae2b_698aed2b7131 -->|calls| 2899e942_a23d_574e_8d47_d28e895c2604
  style 52171b08_09ce_e66b_ae2b_698aed2b7131 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binding/binding_test.go lines 1406–1429

func testProtoBodyBindingFail(t *testing.T, b Binding, name, path, badPath, body, badBody string) {
	assert.Equal(t, name, b.Name())

	obj := protoexample.Test{}
	req := requestWithBody(http.MethodPost, path, body)

	req.Body = io.NopCloser(&hook{})
	req.Header.Add("Content-Type", MIMEPROTOBUF)
	err := b.Bind(req, &obj)
	require.Error(t, err)

	invalidobj := FooStruct{}
	req.Body = io.NopCloser(strings.NewReader(`{"msg":"hello"}`))
	req.Header.Add("Content-Type", MIMEPROTOBUF)
	err = b.Bind(req, &invalidobj)
	require.Error(t, err)
	assert.Equal(t, "obj is not ProtoMessage", err.Error())

	obj = protoexample.Test{}
	req = requestWithBody(http.MethodPost, badPath, badBody)
	req.Header.Add("Content-Type", MIMEPROTOBUF)
	err = ProtoBuf.Bind(req, &obj)
	require.Error(t, err)
}

Domain

Subdomains

Frequently Asked Questions

What does testProtoBodyBindingFail() do?
testProtoBodyBindingFail() is a function in the gin codebase.
What does testProtoBodyBindingFail() call?
testProtoBodyBindingFail() calls 1 function(s): requestWithBody.
What calls testProtoBodyBindingFail()?
testProtoBodyBindingFail() is called by 1 function(s): TestBindingProtoBufFail.

Analyze Your Own Codebase

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

Try Supermodel Free