test and fix internal/reqdata #8

Manually merged
xdrm-brackets merged 21 commits from test/internal/reqdata into 0.2.0 2020-03-02 21:52:08 +00:00
1 changed files with 4 additions and 4 deletions
Showing only changes of commit ee34abd424 - Show all commits

View File

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