Home / Function/ Test_QueryBinder_Bind() — fiber Function Reference

Test_QueryBinder_Bind() — fiber Function Reference

Architecture documentation for the Test_QueryBinder_Bind() function in query_test.go from the fiber codebase.

Entity Profile

Dependency Diagram

graph TD
  d0126ce5_c9c0_6fba_4724_2b995d8dc6ea["Test_QueryBinder_Bind()"]
  ec649929_2505_8592_7c6d_a7dfe7415aef["query_test.go"]
  d0126ce5_c9c0_6fba_4724_2b995d8dc6ea -->|defined in| ec649929_2505_8592_7c6d_a7dfe7415aef
  style d0126ce5_c9c0_6fba_4724_2b995d8dc6ea fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

binder/query_test.go lines 10–51

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

	b := &QueryBinding{
		EnableSplitting: true,
	}
	require.Equal(t, "query", b.Name())

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

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

	req := fasthttp.AcquireRequest()
	req.URI().SetQueryString("name=john&names=john,doe&age=42&posts[0][title]=post1&posts[1][title]=post2&posts[2][title]=post3")

	t.Cleanup(func() {
		fasthttp.ReleaseRequest(req)
	})

	err := b.Bind(req, &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)
	require.Contains(t, user.Names, "john")
	require.Contains(t, user.Names, "doe")

	b.Reset()
	require.False(t, b.EnableSplitting)
}

Domain

Subdomains

Frequently Asked Questions

What does Test_QueryBinder_Bind() do?
Test_QueryBinder_Bind() is a function in the fiber codebase, defined in binder/query_test.go.
Where is Test_QueryBinder_Bind() defined?
Test_QueryBinder_Bind() is defined in binder/query_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