Skip to content

Commit

Permalink
Merge pull request #1 from netr/dev-fix-create-request-headers
Browse files Browse the repository at this point in the history
Fix bug where headers were not being added for requests that didn't h…
  • Loading branch information
netr authored Apr 8, 2024
2 parents d937576 + 2f69b98 commit 21534f3
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions trex/trex.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/bitly/go-simplejson"
"github.com/gofiber/fiber/v2"
"github.com/steinfletcher/apitest-jsonpath/jsonpath"
"github.com/stretchr/testify/require"
"io"
"net/http"
"net/http/httptest"
"net/url"
"reflect"
"regexp"
"strings"

"github.com/bitly/go-simplejson"
"github.com/gofiber/fiber/v2"
"github.com/steinfletcher/apitest-jsonpath/jsonpath"
"github.com/stretchr/testify/require"
)

func New(s IFiberTestSuite) *TestResponse {
Expand Down Expand Up @@ -380,6 +381,12 @@ func createRequest(method, url string, postData *url.Values, headers *http.Heade
var req *http.Request
if postData == nil {
req = httptest.NewRequest(method, url, nil)
if headers != nil {
// add the parameter headers into the requests headers
for key, value := range *headers {
req.Header.Add(key, value[0])
}
}
} else {
if headers != nil && headers.Get(fiber.HeaderContentType) == "application/json" {
req = httptest.NewRequest(method, url, strings.NewReader(convertUrlValuesToJson(postData)))
Expand Down

0 comments on commit 21534f3

Please sign in to comment.