Home / Function/ Test_Msgpack_Binding_Bind() — fiber Function Reference

Test_Msgpack_Binding_Bind() — fiber Function Reference

Architecture documentation for the Test_Msgpack_Binding_Bind() function in msgpack_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  a143caec_ba9f_104b_1346_0692fa4f27e7["Test_Msgpack_Binding_Bind()"]
  7fad0068_48d2_1c8d_0423_cf4802872c93["msgpack_test.go"]
  a143caec_ba9f_104b_1346_0692fa4f27e7 -->|defined in| 7fad0068_48d2_1c8d_0423_cf4802872c93
  style a143caec_ba9f_104b_1346_0692fa4f27e7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binder/msgpack_test.go lines 10–53

func Test_Msgpack_Binding_Bind(t *testing.T) {
	t.Parallel()

	b := &MsgPackBinding{
		MsgPackDecoder: msgpack.Unmarshal,
	}
	require.Equal(t, "msgpack", b.Name())

	type Post struct {
		Title string `msgpack:"title"`
	}

	type User struct {
		Name  string `msgpack:"name"`
		Posts []Post `msgpack:"posts"`
		Age   int    `msgpack:"age"`
	}
	var user User

	// Prepare msgpack data
	input := map[string]any{
		"name": "john",
		"age":  42,
		"posts": []map[string]any{
			{"title": "post1"},
			{"title": "post2"},
			{"title": "post3"},
		},
	}
	data, err := msgpack.Marshal(input)
	require.NoError(t, err)

	err = b.Bind(data, &user)
	require.NoError(t, err)
	require.Equal(t, "john", user.Name)
	require.Equal(t, 42, user.Age)
	require.Len(t, user.Posts, 3)
	require.Equal(t, "post1", user.Posts[0].Title)
	require.Equal(t, "post2", user.Posts[1].Title)
	require.Equal(t, "post3", user.Posts[2].Title)

	b.Reset()
	require.Nil(t, b.MsgPackDecoder)
}

Domain

Subdomains

Frequently Asked Questions

What does Test_Msgpack_Binding_Bind() do?
Test_Msgpack_Binding_Bind() is a function in the fiber codebase, defined in binder/msgpack_test.go.
Where is Test_Msgpack_Binding_Bind() defined?
Test_Msgpack_Binding_Bind() is defined in binder/msgpack_test.go at line 10.

Analyze Your Own Codebase

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

Try Supermodel Free