MCPcopy
hub / github.com/gin-gonic/gin / TestFormMultipartBindingBindError

Function TestFormMultipartBindingBindError

binding/multipart_form_mapping_test.go:72–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

70}
71
72func TestFormMultipartBindingBindError(t *testing.T) {
73 files := []testFile{
74 {"file", "file1", []byte("hello")},
75 {"file", "file2", []byte("world")},
76 }
77
78 for _, tt := range []struct {
79 name string
80 s any
81 }{
82 {"wrong type", &struct {
83 Files int `form:"file"`
84 }{}},
85 {"wrong array size", &struct {
86 Files [1]*multipart.FileHeader `form:"file"`
87 }{}},
88 {"wrong slice type", &struct {
89 Files []int `form:"file"`
90 }{}},
91 } {
92 req := createRequestMultipartFiles(t, files...)
93 err := FormMultipart.Bind(req, tt.s)
94 require.Error(t, err)
95 }
96}
97
98type testFile struct {
99 Fieldname string

Callers

nothing calls this directly

Calls 3

BindMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected