handle unhandled error in context_test.go

This commit is contained in:
Kamandlou 2022-09-01 17:14:35 +04:30
parent 184f2f8ff0
commit c99b84ccfa

View File

@ -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())