test http post

This commit is contained in:
Bruce 2018-09-19 15:43:22 +08:00
parent 1c71600431
commit c985cedb66
No known key found for this signature in database
GPG Key ID: C715526B381CAF28

View File

@ -23,8 +23,9 @@ func TestUploadFormFile(t *testing.T) {
}
// create form data
var body bytes.Buffer
writer := multipart.NewWriter(&body)
body := new(bytes.Buffer)
//body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
formFile, err := writer.CreateFormFile("file", filepath.Base(filePath))
if err != nil {
t.Fatal(err)
@ -35,7 +36,7 @@ func TestUploadFormFile(t *testing.T) {
writer.Close()
// create http post request
req, err := http.NewRequest(http.MethodPost, url, &body)
req, err := http.NewRequest(http.MethodPost, url, body)
if err != nil {
t.Fatal(err)
}