form_test.go — fiber Source File
Architecture documentation for form_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 9e2874af_daa9_2d85_5c35_752d6b7678f6["form_test.go"] c0b86961_3ef1_0168_52fc_98627566ed27["bytes"] 9e2874af_daa9_2d85_5c35_752d6b7678f6 --> c0b86961_3ef1_0168_52fc_98627566ed27 style 9e2874af_daa9_2d85_5c35_752d6b7678f6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package binder
import (
"bytes"
"io"
"mime/multipart"
"testing"
"github.com/stretchr/testify/require"
"github.com/valyala/fasthttp"
)
func Test_FormBinder_Bind(t *testing.T) {
t.Parallel()
b := &FormBinding{
EnableSplitting: true,
}
require.Equal(t, "form", b.Name())
type Post struct {
Title string `form:"title"`
}
type User struct {
Name string `form:"name"`
Names []string `form:"names"`
Posts []Post `form:"posts"`
Age int `form:"age"`
}
var user User
req := fasthttp.AcquireRequest()
req.SetBodyString("name=john&names=john,doe&age=42&posts[0][title]=post1&posts[1][title]=post2&posts[2][title]=post3")
req.Header.SetContentType("application/x-www-form-urlencoded")
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)
}
func Test_FormBinder_Bind_ParseError(t *testing.T) {
b := &FormBinding{}
type User struct {
Age int `form:"age"`
// ... (306 more lines)
Domain
Subdomains
Functions
- Benchmark_FormBinder_Bind()
- Benchmark_FormBinder_BindMultipart()
- Test_FormBinder_Bind()
- Test_FormBinder_BindMultipart()
- Test_FormBinder_BindMultipart_FileError()
- Test_FormBinder_BindMultipart_MapsClearedBetweenRequests()
- Test_FormBinder_BindMultipart_ValueError()
- Test_FormBinder_Bind_MapClearedBetweenRequests()
- Test_FormBinder_Bind_ParseError()
Dependencies
- bytes
Source
Frequently Asked Questions
What does form_test.go do?
form_test.go is a source file in the fiber codebase, written in go. It belongs to the DataBinding domain, PayloadParsers subdomain.
What functions are defined in form_test.go?
form_test.go defines 9 function(s): Benchmark_FormBinder_Bind, Benchmark_FormBinder_BindMultipart, Test_FormBinder_Bind, Test_FormBinder_BindMultipart, Test_FormBinder_BindMultipart_FileError, Test_FormBinder_BindMultipart_MapsClearedBetweenRequests, Test_FormBinder_BindMultipart_ValueError, Test_FormBinder_Bind_MapClearedBetweenRequests, Test_FormBinder_Bind_ParseError.
What does form_test.go depend on?
form_test.go imports 1 module(s): bytes.
Where is form_test.go in the architecture?
form_test.go is located at binder/form_test.go (domain: DataBinding, subdomain: PayloadParsers, directory: binder).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free