mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-25 14:26:04 +03:00
test http post
This commit is contained in:
parent
1c71600431
commit
c985cedb66
@ -23,8 +23,9 @@ func TestUploadFormFile(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create form data
|
// create form data
|
||||||
var body bytes.Buffer
|
body := new(bytes.Buffer)
|
||||||
writer := multipart.NewWriter(&body)
|
//body := &bytes.Buffer{}
|
||||||
|
writer := multipart.NewWriter(body)
|
||||||
formFile, err := writer.CreateFormFile("file", filepath.Base(filePath))
|
formFile, err := writer.CreateFormFile("file", filepath.Base(filePath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -35,7 +36,7 @@ func TestUploadFormFile(t *testing.T) {
|
|||||||
writer.Close()
|
writer.Close()
|
||||||
|
|
||||||
// create http post request
|
// create http post request
|
||||||
req, err := http.NewRequest(http.MethodPost, url, &body)
|
req, err := http.NewRequest(http.MethodPost, url, body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user