replace bytes.NewBufferString() with strings.NewReader()

This commit is contained in:
Adrien Marquès 2019-11-21 23:00:42 +01:00
parent 727737ae67
commit f076f3a88a
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
1 changed files with 4 additions and 4 deletions

View File

@ -1,11 +1,11 @@
package reqdata
import (
"bytes"
"fmt"
"net/http"
"net/http/httptest"
"reflect"
"strings"
"testing"
)
@ -301,7 +301,7 @@ func TestStoreWithUrlEncodedForm(t *testing.T) {
for i, test := range tests {
t.Run(fmt.Sprintf("request.%d", i), func(t *testing.T) {
body := bytes.NewBufferString(test.URLEncoded)
body := strings.NewReader(test.URLEncoded)
req := httptest.NewRequest(http.MethodPost, "http://host.com", body)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
defer req.Body.Close()
@ -474,7 +474,7 @@ func TestJsonParameters(t *testing.T) {
for i, test := range tests {
t.Run(fmt.Sprintf("request.%d", i), func(t *testing.T) {
body := bytes.NewBufferString(test.RawJson)
body := strings.NewReader(test.RawJson)
req := httptest.NewRequest(http.MethodPost, "http://host.com", body)
req.Header.Add("Content-Type", "application/json")
defer req.Body.Close()
@ -709,7 +709,7 @@ x
for i, test := range tests {
t.Run(fmt.Sprintf("request.%d", i), func(t *testing.T) {
body := bytes.NewBufferString(test.RawMultipart)
body := strings.NewReader(test.RawMultipart)
req := httptest.NewRequest(http.MethodPost, "http://host.com", body)
req.Header.Add("Content-Type", "multipart/form-data; boundary=xxx")
defer req.Body.Close()