diff --git a/README.md b/README.md index e8911f39..371a0c21 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ func TestCaseDemo(t *testing.T) { hrp.Step("post form data"). POST("/post"). WithHeaders(map[string]string{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}). - WithParams(map[string]interface{}{ + WithBody(map[string]interface{}{ "foo1": "$varFoo1", // reference former extracted variable "foo2": "${max($a, $b)}", // 12.3; step level variables are independent, variable b is 3.45 here }). diff --git a/examples/demo_test.go b/examples/demo_test.go index f7c19e82..0f93ac39 100644 --- a/examples/demo_test.go +++ b/examples/demo_test.go @@ -50,7 +50,7 @@ func TestCaseDemo(t *testing.T) { hrp.Step("post form data"). POST("/post"). WithHeaders(map[string]string{"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}). - WithParams(map[string]interface{}{ + WithBody(map[string]interface{}{ "foo1": "$varFoo1", // reference former extracted variable "foo2": "${max($a, $b)}", // 12.3; step level variables are independent, variable b is 3.45 here }). diff --git a/examples/request_test.go b/examples/request_test.go index 433e593e..c0d41b55 100644 --- a/examples/request_test.go +++ b/examples/request_test.go @@ -17,7 +17,9 @@ func TestCaseBasicRequest(t *testing.T) { hrp.Step("get with params"). GET("/get"). WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). - WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). + WithHeaders(map[string]string{ + "User-Agent": "HttpRunnerPlus", + }). Validate(). AssertEqual("status_code", 200, "check status code"). AssertEqual("headers.Connection", "keep-alive", "check header Connection"). @@ -26,22 +28,30 @@ func TestCaseBasicRequest(t *testing.T) { AssertEqual("body.args.foo2", "bar2", "check args foo2"), hrp.Step("post raw text"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "text/plain"}). + WithHeaders(map[string]string{ + "User-Agent": "HttpRunnerPlus", + "Content-Type": "text/plain", + }). WithBody("This is expected to be sent back as part of response body."). Validate(). AssertEqual("status_code", 200, "check status code"). AssertEqual("body.data", "This is expected to be sent back as part of response body.", "check data"), hrp.Step("post form data"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "application/x-www-form-urlencoded"}). - WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). + WithHeaders(map[string]string{ + "User-Agent": "HttpRunnerPlus", + "Content-Type": "application/x-www-form-urlencoded", + }). + WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). Validate(). AssertEqual("status_code", 200, "check status code"). AssertEqual("body.form.foo1", "bar1", "check form foo1"). AssertEqual("body.form.foo2", "bar2", "check form foo2"), hrp.Step("post json data"). POST("/post"). - WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). + WithHeaders(map[string]string{ + "User-Agent": "HttpRunnerPlus", + }). WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}). Validate(). AssertEqual("status_code", 200, "check status code"). @@ -49,7 +59,10 @@ func TestCaseBasicRequest(t *testing.T) { AssertEqual("body.json.foo2", "bar2", "check json foo2"), hrp.Step("put request"). PUT("/put"). - WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "text/plain"}). + WithHeaders(map[string]string{ + "User-Agent": "HttpRunnerPlus", + "Content-Type": "text/plain", + }). WithBody("This is expected to be sent back as part of response body."). Validate(). AssertEqual("status_code", 200, "check status code").