mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-18 20:57:37 +08:00
refactor: rename to hrp
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
},
|
||||
{
|
||||
"name": "User-Agent",
|
||||
"value": "HttpBoomer"
|
||||
"value": "HttpRunnerPlus"
|
||||
},
|
||||
{
|
||||
"name": "Accept-Encoding",
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"foo2": "$varFoo2"
|
||||
},
|
||||
"headers": {
|
||||
"User-Agent": "HttpBoomer"
|
||||
"User-Agent": "HttpRunnerPlus"
|
||||
}
|
||||
},
|
||||
"variables": {
|
||||
|
||||
@@ -16,7 +16,7 @@ teststeps:
|
||||
foo1: $varFoo1
|
||||
foo2: $varFoo2
|
||||
headers:
|
||||
User-Agent: HttpBoomer
|
||||
User-Agent: HttpRunnerPlus
|
||||
variables:
|
||||
b: 34.5
|
||||
"n": 3
|
||||
|
||||
@@ -3,12 +3,12 @@ package examples
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httpboomer"
|
||||
"github.com/httprunner/hrp"
|
||||
)
|
||||
|
||||
func TestCaseDemo(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "demo with complex mechanisms",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Variables: map[string]interface{}{ // global level variables
|
||||
@@ -19,8 +19,8 @@ func TestCaseDemo(t *testing.T) {
|
||||
"varFoo2": "${max($a, $b)}", // 12.3; eval with built-in function
|
||||
},
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
WithVariables(map[string]interface{}{ // step level variables
|
||||
"n": 3, // inherit config level variables if not set in step level, a/varFoo1
|
||||
"b": 34.5, // override config level variable if existed, n/b/varFoo2
|
||||
@@ -28,7 +28,7 @@ func TestCaseDemo(t *testing.T) {
|
||||
}).
|
||||
GET("/get").
|
||||
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}). // request with params
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}). // request with headers
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). // request with headers
|
||||
Extract().
|
||||
WithJmesPath("body.args.foo1", "varFoo1"). // extract variable with jmespath
|
||||
Validate().
|
||||
@@ -37,7 +37,7 @@ func TestCaseDemo(t *testing.T) {
|
||||
AssertLengthEqual("body.args.foo1", 5, "check args foo1"). // validate response body with jmespath
|
||||
AssertLengthEqual("$varFoo1", 5, "check args foo1"). // assert with extracted variable from current step
|
||||
AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string
|
||||
httpboomer.Step("post json data").
|
||||
hrp.Step("post json data").
|
||||
POST("/post").
|
||||
WithBody(map[string]interface{}{
|
||||
"foo1": "$varFoo1", // reference former extracted variable
|
||||
@@ -47,7 +47,7 @@ func TestCaseDemo(t *testing.T) {
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
AssertLengthEqual("body.json.foo1", 5, "check args foo1").
|
||||
AssertEqual("body.json.foo2", 12.3, "check args foo2"),
|
||||
httpboomer.Step("post form data").
|
||||
hrp.Step("post form data").
|
||||
POST("/post").
|
||||
WithParams(map[string]interface{}{
|
||||
"foo1": "$varFoo1", // reference former extracted variable
|
||||
@@ -60,7 +60,7 @@ func TestCaseDemo(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
|
||||
@@ -3,22 +3,22 @@ package examples
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httpboomer"
|
||||
"github.com/httprunner/hrp"
|
||||
)
|
||||
|
||||
// reference extracted variables for validation in the same step
|
||||
func TestCaseExtractStepSingle(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "run request with variables",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Verify: false,
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
WithVariables(map[string]interface{}{
|
||||
"var1": "bar1",
|
||||
"agent": "HttpBoomer",
|
||||
"agent": "HttpRunnerPlus",
|
||||
"expectedStatusCode": 200,
|
||||
}).
|
||||
GET("/get").
|
||||
@@ -33,11 +33,11 @@ func TestCaseExtractStepSingle(t *testing.T) {
|
||||
AssertEqual("$contentType", "application/json; charset=utf-8", "check header Content-Type"). // assert with extracted variable from current step
|
||||
AssertEqual("$varFoo1", "bar1", "check args foo1"). // assert with extracted variable from current step
|
||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
@@ -45,17 +45,17 @@ func TestCaseExtractStepSingle(t *testing.T) {
|
||||
|
||||
// reference extracted variables from previous step
|
||||
func TestCaseExtractStepAssociation(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "run request with variables",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Verify: false,
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
WithVariables(map[string]interface{}{
|
||||
"var1": "bar1",
|
||||
"agent": "HttpBoomer",
|
||||
"agent": "HttpRunnerPlus",
|
||||
}).
|
||||
GET("/get").
|
||||
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
||||
@@ -70,10 +70,10 @@ func TestCaseExtractStepAssociation(t *testing.T) {
|
||||
AssertEqual("$contentType", "application/json; charset=utf-8", "check header Content-Type").
|
||||
AssertEqual("$varFoo1", "bar1", "check args foo1").
|
||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
||||
httpboomer.Step("post json data").
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||
hrp.Step("post json data").
|
||||
POST("/post").
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||
WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||
Validate().
|
||||
AssertEqual("status_code", "$statusCode", "check status code"). // assert with extracted variable from previous step
|
||||
@@ -82,7 +82,7 @@ func TestCaseExtractStepAssociation(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package examples
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httpboomer"
|
||||
"github.com/httprunner/hrp"
|
||||
)
|
||||
|
||||
func TestCaseCallFunction(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "run request with functions",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Verify: false,
|
||||
@@ -18,20 +18,20 @@ func TestCaseCallFunction(t *testing.T) {
|
||||
"b": 3.45,
|
||||
},
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
GET("/get").
|
||||
WithParams(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||
Extract().
|
||||
WithJmesPath("body.args.foo1", "varFoo1").
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
AssertLengthEqual("body.args.foo1", 5, "check args foo1").
|
||||
AssertEqual("body.args.foo2", "12.3", "check args foo2"), // notice: request params value will be converted to string
|
||||
httpboomer.Step("post json data with functions").
|
||||
hrp.Step("post json data with functions").
|
||||
POST("/post").
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||
WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
@@ -40,7 +40,7 @@ func TestCaseCallFunction(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
|
||||
@@ -3,53 +3,53 @@ package examples
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httpboomer"
|
||||
"github.com/httprunner/hrp"
|
||||
)
|
||||
|
||||
func TestCaseBasicRequest(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "request methods testcase in hardcode",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Verify: false,
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
GET("/get").
|
||||
WithParams(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
AssertEqual("headers.Connection", "keep-alive", "check header Connection").
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
||||
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
||||
AssertEqual("body.args.foo2", "bar2", "check args foo2"),
|
||||
httpboomer.Step("post raw text").
|
||||
hrp.Step("post raw text").
|
||||
POST("/post").
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "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"),
|
||||
httpboomer.Step("post form data").
|
||||
hrp.Step("post form data").
|
||||
POST("/post").
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "Content-Type": "application/x-www-form-urlencoded"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus", "Content-Type": "application/x-www-form-urlencoded"}).
|
||||
WithParams(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"),
|
||||
httpboomer.Step("post json data").
|
||||
hrp.Step("post json data").
|
||||
POST("/post").
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||
WithBody(map[string]interface{}{"foo1": "bar1", "foo2": "bar2"}).
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
AssertEqual("body.json.foo1", "bar1", "check json foo1").
|
||||
AssertEqual("body.json.foo2", "bar2", "check json foo2"),
|
||||
httpboomer.Step("put request").
|
||||
hrp.Step("put request").
|
||||
PUT("/put").
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer", "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").
|
||||
@@ -57,7 +57,7 @@ func TestCaseBasicRequest(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
|
||||
@@ -3,21 +3,21 @@ package examples
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httpboomer"
|
||||
"github.com/httprunner/hrp"
|
||||
)
|
||||
|
||||
func TestCaseValidateStep(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "run request with validation",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Verify: false,
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
WithVariables(map[string]interface{}{
|
||||
"var1": "bar1",
|
||||
"agent": "HttpBoomer",
|
||||
"agent": "HttpRunnerPlus",
|
||||
"expectedStatusCode": 200,
|
||||
}).
|
||||
GET("/get").
|
||||
@@ -31,11 +31,11 @@ func TestCaseValidateStep(t *testing.T) {
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). // assert response header, with double quotes
|
||||
AssertEqual("body.args.foo1", "bar1", "check args foo1"). // assert response json body with jmespath
|
||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
||||
httpboomer.Step("get with params").
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||
hrp.Step("get with params").
|
||||
WithVariables(map[string]interface{}{
|
||||
"var1": "bar1",
|
||||
"agent": "HttpBoomer",
|
||||
"agent": "HttpRunnerPlus",
|
||||
}).
|
||||
GET("/get").
|
||||
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
||||
@@ -51,7 +51,7 @@ func TestCaseValidateStep(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
|
||||
@@ -3,23 +3,23 @@ package examples
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/httprunner/httpboomer"
|
||||
"github.com/httprunner/hrp"
|
||||
)
|
||||
|
||||
func TestCaseConfigVariables(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "run request with variables",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Variables: map[string]interface{}{
|
||||
"var1": "bar1",
|
||||
"agent": "HttpBoomer",
|
||||
"agent": "HttpRunnerPlus",
|
||||
"expectedStatusCode": 200,
|
||||
},
|
||||
Verify: false,
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
GET("/get").
|
||||
WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "$agent"}).
|
||||
@@ -29,28 +29,28 @@ func TestCaseConfigVariables(t *testing.T) {
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
||||
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCaseStepVariables(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "run request with variables",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Verify: false,
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
WithVariables(map[string]interface{}{
|
||||
"var1": "bar1",
|
||||
"agent": "HttpBoomer",
|
||||
"agent": "HttpRunnerPlus",
|
||||
"expectedStatusCode": 200,
|
||||
}).
|
||||
GET("/get").
|
||||
@@ -62,30 +62,30 @@ func TestCaseStepVariables(t *testing.T) {
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
||||
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCaseOverrideConfigVariables(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "run request with variables",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Variables: map[string]interface{}{
|
||||
"var1": "bar0",
|
||||
"agent": "HttpBoomer",
|
||||
"agent": "HttpRunnerPlus",
|
||||
"expectedStatusCode": 200,
|
||||
},
|
||||
Verify: false,
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
WithVariables(map[string]interface{}{
|
||||
"var1": "bar1", // override config variable
|
||||
"agent": "$agent", // reference config variable
|
||||
@@ -100,19 +100,19 @@ func TestCaseOverrideConfigVariables(t *testing.T) {
|
||||
AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type").
|
||||
AssertEqual("body.args.foo1", "bar1", "check args foo1").
|
||||
AssertEqual("body.args.foo2", "bar2", "check args foo2").
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpBoomer", "check header user agent"),
|
||||
AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"),
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCaseParseVariables(t *testing.T) {
|
||||
testcase := &httpboomer.TestCase{
|
||||
Config: httpboomer.TConfig{
|
||||
testcase := &hrp.TestCase{
|
||||
Config: hrp.TConfig{
|
||||
Name: "run request with functions",
|
||||
BaseURL: "https://postman-echo.com",
|
||||
Verify: false,
|
||||
@@ -124,8 +124,8 @@ func TestCaseParseVariables(t *testing.T) {
|
||||
"varFoo2": "${max($a, $b)}", // 12.3
|
||||
},
|
||||
},
|
||||
TestSteps: []httpboomer.IStep{
|
||||
httpboomer.Step("get with params").
|
||||
TestSteps: []hrp.IStep{
|
||||
hrp.Step("get with params").
|
||||
WithVariables(map[string]interface{}{
|
||||
"n": 3,
|
||||
"b": 34.5,
|
||||
@@ -133,16 +133,16 @@ func TestCaseParseVariables(t *testing.T) {
|
||||
}).
|
||||
GET("/get").
|
||||
WithParams(map[string]interface{}{"foo1": "$varFoo1", "foo2": "$varFoo2"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||
Extract().
|
||||
WithJmesPath("body.args.foo1", "varFoo1").
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
AssertLengthEqual("body.args.foo1", 5, "check args foo1").
|
||||
AssertEqual("body.args.foo2", "34.5", "check args foo2"), // notice: request params value will be converted to string
|
||||
httpboomer.Step("post json data with functions").
|
||||
hrp.Step("post json data with functions").
|
||||
POST("/post").
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpBoomer"}).
|
||||
WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}).
|
||||
WithBody(map[string]interface{}{"foo1": "${gen_random_string($n)}", "foo2": "${max($a, $b)}"}).
|
||||
Validate().
|
||||
AssertEqual("status_code", 200, "check status code").
|
||||
@@ -151,7 +151,7 @@ func TestCaseParseVariables(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
err := httpboomer.Run(t, testcase)
|
||||
err := hrp.Run(t, testcase)
|
||||
if err != nil {
|
||||
t.Fatalf("run testcase error: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user