test http post

This commit is contained in:
Bruce 2018-09-19 15:47:46 +08:00
parent c985cedb66
commit 52811552c6
No known key found for this signature in database
GPG Key ID: C715526B381CAF28

View File

@ -26,11 +26,11 @@ func TestUploadFormFile(t *testing.T) {
body := new(bytes.Buffer) body := new(bytes.Buffer)
//body := &bytes.Buffer{} //body := &bytes.Buffer{}
writer := multipart.NewWriter(body) writer := multipart.NewWriter(body)
formFile, err := writer.CreateFormFile("file", filepath.Base(filePath)) formFileWriter, err := writer.CreateFormFile("file", filepath.Base(filePath))
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
if _, err = io.Copy(formFile, bytes.NewReader(yamlFile)); err != nil { if _, err = io.Copy(formFileWriter, bytes.NewReader(yamlFile)); err != nil {
t.Fatal(err) t.Fatal(err)
} }
writer.Close() writer.Close()