mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-16 05:16:35 +08:00
handle unhandled error in context_test.go
This commit is contained in:
parent
184f2f8ff0
commit
c99b84ccfa
@ -42,7 +42,7 @@ func createMultipartRequest() *http.Request {
|
||||
boundary := "--testboundary"
|
||||
body := new(bytes.Buffer)
|
||||
mw := multipart.NewWriter(body)
|
||||
defer mw.Close()
|
||||
defer must(mw.Close())
|
||||
|
||||
must(mw.SetBoundary(boundary))
|
||||
must(mw.WriteField("foo", "bar"))
|
||||
@ -76,7 +76,7 @@ func TestContextFormFile(t *testing.T) {
|
||||
_, err = w.Write([]byte("test"))
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
mw.Close()
|
||||
must(mw.Close())
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
c.Request, _ = http.NewRequest("POST", "/", buf)
|
||||
c.Request.Header.Set("Content-Type", mw.FormDataContentType())
|
||||
@ -97,7 +97,7 @@ func TestContextMultipartForm(t *testing.T) {
|
||||
_, err = w.Write([]byte("test"))
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
mw.Close()
|
||||
must(mw.Close())
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
c.Request, _ = http.NewRequest("POST", "/", buf)
|
||||
c.Request.Header.Set("Content-Type", mw.FormDataContentType())
|
||||
@ -112,7 +112,7 @@ func TestContextMultipartForm(t *testing.T) {
|
||||
func TestSaveUploadedOpenFailed(t *testing.T) {
|
||||
buf := new(bytes.Buffer)
|
||||
mw := multipart.NewWriter(buf)
|
||||
mw.Close()
|
||||
must(mw.Close())
|
||||
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
c.Request, _ = http.NewRequest("POST", "/", buf)
|
||||
@ -132,7 +132,7 @@ func TestSaveUploadedCreateFailed(t *testing.T) {
|
||||
_, err = w.Write([]byte("test"))
|
||||
assert.NoError(t, err)
|
||||
}
|
||||
mw.Close()
|
||||
must(mw.Close())
|
||||
c, _ := CreateTestContext(httptest.NewRecorder())
|
||||
c.Request, _ = http.NewRequest("POST", "/", buf)
|
||||
c.Request.Header.Set("Content-Type", mw.FormDataContentType())
|
||||
|
Loading…
x
Reference in New Issue
Block a user