(t *testing.T)
| 36 | } |
| 37 | |
| 38 | func TestCaseStepVariables(t *testing.T) { |
| 39 | testcase := &hrp.TestCase{ |
| 40 | Config: hrp.NewConfig("run request with variables"). |
| 41 | SetBaseURL("https://postman-echo.com"). |
| 42 | SetVerifySSL(false), |
| 43 | TestSteps: []hrp.IStep{ |
| 44 | hrp.NewStep("get with params"). |
| 45 | WithVariables(map[string]interface{}{ |
| 46 | "var1": "bar1", |
| 47 | "agent": "HttpRunnerPlus", |
| 48 | "expectedStatusCode": 200, |
| 49 | }). |
| 50 | GET("/get"). |
| 51 | WithParams(map[string]interface{}{"foo1": "$var1", "foo2": "bar2"}). |
| 52 | WithHeaders(map[string]string{"User-Agent": "$agent"}). |
| 53 | Validate(). |
| 54 | AssertEqual("status_code", "$expectedStatusCode", "check status code"). |
| 55 | AssertEqual("headers.\"Content-Type\"", "application/json; charset=utf-8", "check header Content-Type"). |
| 56 | AssertEqual("body.args.foo1", "bar1", "check args foo1"). |
| 57 | AssertEqual("body.args.foo2", "bar2", "check args foo2"). |
| 58 | AssertEqual("body.headers.\"user-agent\"", "HttpRunnerPlus", "check header user agent"), |
| 59 | }, |
| 60 | } |
| 61 | |
| 62 | err := hrp.NewRunner(t).Run(testcase) |
| 63 | if err != nil { |
| 64 | t.Fatalf("run testcase error: %v", err) |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | func TestCaseOverrideConfigVariables(t *testing.T) { |
| 69 | testcase := &hrp.TestCase{ |
nothing calls this directly
no test coverage detected