...
1
2
3
4
5
6
7 package gin
8
9 import (
10 "bytes"
11 "mime/multipart"
12 "net/http"
13 "net/http/httptest"
14 "testing"
15
16 "github.com/stretchr/testify/assert"
17 )
18
19 func TestContextFormFileFailed19(t *testing.T) {
20 buf := new(bytes.Buffer)
21 mw := multipart.NewWriter(buf)
22 mw.Close()
23 c, _ := CreateTestContext(httptest.NewRecorder())
24 c.Request, _ = http.NewRequest("POST", "/", nil)
25 c.Request.Header.Set("Content-Type", mw.FormDataContentType())
26 c.engine.MaxMultipartMemory = 8 << 20
27 f, err := c.FormFile("file")
28 assert.Error(t, err)
29 assert.Nil(t, f)
30 }
31
View as plain text