mirror of
https://github.com/gotenberg/gotenberg.git
synced 2026-08-16 20:32:13 +01:00
test(integration): allow repeated form fields in requests
This commit is contained in:
@@ -29,14 +29,16 @@ func doRequest(method, url string, headers map[string]string, body io.Reader) (*
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func doFormDataRequest(method, url string, fields map[string]string, files map[string][]string, headers map[string]string) (*http.Response, error) {
|
func doFormDataRequest(method, url string, fields map[string][]string, files map[string][]string, headers map[string]string) (*http.Response, error) {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
writer := multipart.NewWriter(&b)
|
writer := multipart.NewWriter(&b)
|
||||||
|
|
||||||
for name, value := range fields {
|
for name, values := range fields {
|
||||||
err := writer.WriteField(name, value)
|
for _, value := range values {
|
||||||
if err != nil {
|
err := writer.WriteField(name, value)
|
||||||
return nil, fmt.Errorf("write field %q: %w", name, err)
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("write field %q: %w", name, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ func (s *scenario) iMakeARequestToGotenbergWithTheFollowingFormDataAndHeaders(ct
|
|||||||
return errors.New("no Gotenberg container")
|
return errors.New("no Gotenberg container")
|
||||||
}
|
}
|
||||||
|
|
||||||
fields := make(map[string]string)
|
fields := make(map[string][]string)
|
||||||
files := make(map[string][]string)
|
files := make(map[string][]string)
|
||||||
headers := make(map[string]string)
|
headers := make(map[string]string)
|
||||||
|
|
||||||
@@ -220,10 +220,10 @@ func (s *scenario) iMakeARequestToGotenbergWithTheFollowingFormDataAndHeaders(ct
|
|||||||
switch kind {
|
switch kind {
|
||||||
case "field":
|
case "field":
|
||||||
if name == "downloadFrom" || name == "url" || name == "cookies" {
|
if name == "downloadFrom" || name == "url" || name == "cookies" {
|
||||||
fields[name] = strings.ReplaceAll(value, "%d", fmt.Sprintf("%d", s.hostPort))
|
fields[name] = append(fields[name], strings.ReplaceAll(value, "%d", fmt.Sprintf("%d", s.hostPort)))
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
fields[name] = value
|
fields[name] = append(fields[name], value)
|
||||||
case "file":
|
case "file":
|
||||||
if strings.Contains(value, "teststore") {
|
if strings.Contains(value, "teststore") {
|
||||||
if s.teststoreDir == "" {
|
if s.teststoreDir == "" {
|
||||||
@@ -363,7 +363,7 @@ func (s *scenario) iMakeConcurrentRequestsToGotenberg(ctx context.Context, count
|
|||||||
return errors.New("no Gotenberg container")
|
return errors.New("no Gotenberg container")
|
||||||
}
|
}
|
||||||
|
|
||||||
fields := make(map[string]string)
|
fields := make(map[string][]string)
|
||||||
files := make(map[string][]string)
|
files := make(map[string][]string)
|
||||||
headers := make(map[string]string)
|
headers := make(map[string]string)
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ func (s *scenario) iMakeConcurrentRequestsToGotenberg(ctx context.Context, count
|
|||||||
|
|
||||||
switch kind {
|
switch kind {
|
||||||
case "field":
|
case "field":
|
||||||
fields[name] = value
|
fields[name] = append(fields[name], value)
|
||||||
case "file":
|
case "file":
|
||||||
wd, err := os.Getwd()
|
wd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user