Changed assets endpoint to multipart

This commit is contained in:
2022-02-06 16:53:53 +01:00
parent d4ac4409ad
commit 8bc01e0984
3 changed files with 102 additions and 26 deletions

View File

@@ -16,9 +16,10 @@ import (
type testInformation struct {
Method string
Header map[string]string
Cookie map[string]string
Body interface{}
Query map[string]interface{}
Cookie map[string]string
ResultBody interface{}
ResultCookie []string
@@ -57,8 +58,12 @@ func checkTestInformation(t *testing.T, url string, information []testInformatio
for i, information := range information {
var body io.Reader
if information.Body != nil {
buf, _ := json.Marshal(information.Body)
body = bytes.NewReader(buf)
if b, ok := information.Body.([]byte); ok {
body = bytes.NewReader(b)
} else {
buf, _ := json.Marshal(information.Body)
body = bytes.NewReader(buf)
}
}
query := url2.Values{}
@@ -77,6 +82,11 @@ func checkTestInformation(t *testing.T, url string, information []testInformatio
})
}
}
if information.Header != nil {
for name, value := range information.Header {
req.Header.Set(name, value)
}
}
resp, _ := http.DefaultClient.Do(req)