feat: support post json

This commit is contained in:
debugtalk
2021-09-23 21:53:30 +08:00
parent 961950b35d
commit e1f723e47e
2 changed files with 7 additions and 0 deletions

View File

@@ -32,6 +32,12 @@ func TestCaseHardcode(t *testing.T) {
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
Validate().
AssertEqual("status_code", 200, "check status code"),
httpboomer.Step("post json data").
POST("/post").
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
WithJSON(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
Validate().
AssertEqual("status_code", 200, "check status code"),
httpboomer.Step("put request").
PUT("/put").
WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "text/plain"}).

View File

@@ -59,6 +59,7 @@ func (r *Runner) runStep(step *TStep) error {
v = append(v, req.Header(step.Request.Headers))
v = append(v, req.Param(step.Request.Params))
v = append(v, step.Request.Data)
v = append(v, req.BodyJSON(step.Request.JSON))
for cookieName, cookieValue := range step.Request.Cookies {
v = append(v, &http.Cookie{