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 RequestBinding FormBinding calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  1ed726d8_0cb9_b9b3_f6b0_56d032ab84ab["testProtoBodyBindingFail()"]
  314c6481_2bd0_e5a7_282c_94e41df6062a["binding_test.go"]
  1ed726d8_0cb9_b9b3_f6b0_56d032ab84ab -->|defined in| 314c6481_2bd0_e5a7_282c_94e41df6062a
  3985ac04_44b0_a597_a0be_8af7bb4087c0["TestBindingProtoBufFail()"]
  3985ac04_44b0_a597_a0be_8af7bb4087c0 -->|calls| 1ed726d8_0cb9_b9b3_f6b0_56d032ab84ab
  aebd0564_565b_ba1b_7f92_4baaca0e7b7e["requestWithBody()"]
  1ed726d8_0cb9_b9b3_f6b0_56d032ab84ab -->|calls| aebd0564_565b_ba1b_7f92_4baaca0e7b7e
  style 1ed726d8_0cb9_b9b3_f6b0_56d032ab84ab 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)
}

Subdomains

Frequently Asked Questions

What does testProtoBodyBindingFail() do?
testProtoBodyBindingFail() is a function in the gin codebase, defined in binding/binding_test.go.
Where is testProtoBodyBindingFail() defined?
testProtoBodyBindingFail() is defined in binding/binding_test.go at line 1406.
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