MCPcopy
hub / github.com/labstack/echo / TestToContext_MultipartForm

Function TestToContext_MultipartForm

echotest/context_test.go:112–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestToContext_MultipartForm(t *testing.T) {
113 testConf := ContextConfig{
114 MultipartForm: &MultipartForm{
115 Fields: map[string]string{
116 "key": "value",
117 },
118 Files: []MultipartFormFile{
119 {
120 Fieldname: "file",
121 Filename: "test.json",
122 Content: LoadBytes(t, "testdata/test.json"),
123 },
124 },
125 },
126 }
127 c := testConf.ToContext(t)
128
129 assert.Equal(t, "value", c.FormValue("key"))
130 assert.Equal(t, http.MethodPost, c.Request().Method)
131 assert.Equal(t, true, strings.HasPrefix(c.Request().Header.Get(echo.HeaderContentType), "multipart/form-data; boundary="))
132
133 fv, err := c.FormFile("file")
134 if err != nil {
135 t.Fatal(err)
136 }
137 assert.Equal(t, "test.json", fv.Filename)
138 assert.Equal(t, int64(23), fv.Size)
139}
140
141func TestToContext_JSONBody(t *testing.T) {
142 testConf := ContextConfig{

Callers

nothing calls this directly

Calls 6

ToContextMethod · 0.95
LoadBytesFunction · 0.85
FormValueMethod · 0.80
RequestMethod · 0.80
FormFileMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…