(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestCaseConfigVariables(t *testing.T) { |
| 10 | testcase := &hrp.TestCase{ |
| 11 | Config: hrp.NewConfig("run request with variables"). |
| 12 | SetBaseURL("https://postman-echo.com"). |
| 13 | WithVariables(map[string]interface{}{ |
| 14 | "var1": "bar1", |
| 15 | "agent": "HttpRunnerPlus", |
| 16 | "expectedStatusCode": 200, |
| 17 | }).SetVerifySSL(false), |
| 18 | TestSteps: []hrp.IStep{ |
| 19 | hrp.NewStep("get with params"). |
| 20 | GET("/get"). |
| 21 | WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}). |
| 22 | WithHeaders(map[string]string{"User-Agent": "$agent"}). |
| 23 | Validate(). |
| 24 | AssertEqual("status_code", "$expectedStatusCode", "check status code"). |
| 25 | AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). |
| 26 | AssertEqual("body.args.foo1", "bar1", "check args foo1"). |
| 27 | AssertEqual("body.args.foo2", "bar2", "check args foo2"). |
| 28 | AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"), |
| 29 | }, |
| 30 | } |
| 31 | |
| 32 | err := hrp.NewRunner(t).Run(testcase) |
| 33 | if err != nil { |
| 34 | t.Fatalf("run testcase error: %v", err) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestCaseStepVariables(t *testing.T) { |
| 39 | testcase := &hrp.TestCase{ |
nothing calls this directly
no test coverage detected