Test_Bind_All() — fiber Function Reference
Architecture documentation for the Test_Bind_All() function in bind_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD 3552c57c_c5a8_c111_52dc_c4936bca80cb["Test_Bind_All()"] 55065b01_f5dc_4e53_5a74_5ecc7aca8f52["bind_test.go"] 3552c57c_c5a8_c111_52dc_c4936bca80cb -->|defined in| 55065b01_f5dc_4e53_5a74_5ecc7aca8f52 style 3552c57c_c5a8_c111_52dc_c4936bca80cb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
bind_test.go lines 2142–2288
func Test_Bind_All(t *testing.T) {
t.Parallel()
type User struct {
Avatar *multipart.FileHeader `form:"avatar"`
Name string `query:"name" json:"name" form:"name"`
Email string `json:"email" form:"email"`
Role string `header:"X-User-Role"`
SessionID string `json:"session_id" cookie:"session_id"`
ID int `uri:"id" query:"id" json:"id" form:"id"`
}
newBind := func(app *App) *Bind {
return &Bind{
ctx: app.AcquireCtx(&fasthttp.RequestCtx{}),
}
}
defaultConfig := func() *RequestConfig {
return &RequestConfig{
ContentType: MIMEApplicationJSON,
Body: []byte(`{"name":"john", "email": "john@doe.com", "session_id": "abc1234", "id": 1}`),
Headers: map[string]string{
"X-User-Role": "admin",
},
Cookies: map[string]string{
"session_id": "abc123",
},
Query: "id=1&name=john",
}
}
tests := []struct {
out any
expected *User
config *RequestConfig
name string
wantErr bool
}{
{
name: "Invalid output type",
out: 123,
wantErr: true,
},
{
name: "Successful binding",
out: new(User),
config: defaultConfig(),
expected: &User{
ID: 1,
Name: "john",
Email: "john@doe.com",
Role: "admin",
SessionID: "abc1234",
},
},
{
name: "Missing fields (partial JSON only)",
out: new(User),
config: &RequestConfig{
ContentType: MIMEApplicationJSON,
Body: []byte(`{"name":"partial"}`),
},
expected: &User{
Name: "partial",
},
},
{
name: "Override query with JSON",
out: new(User),
config: &RequestConfig{
ContentType: MIMEApplicationJSON,
Body: []byte(`{"name":"fromjson", "id": 99}`),
Query: "id=1&name=queryname",
},
expected: &User{
Name: "fromjson",
ID: 99,
},
},
{
name: "Form binding",
out: new(User),
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Bind_All() do?
Test_Bind_All() is a function in the fiber codebase, defined in bind_test.go.
Where is Test_Bind_All() defined?
Test_Bind_All() is defined in bind_test.go at line 2142.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free