(t *testing.T)
| 7 | ) |
| 8 | |
| 9 | func TestHTTPProtocol(t *testing.T) { |
| 10 | testcase := &hrp.TestCase{ |
| 11 | Config: hrp.NewConfig("run request with HTTP/1.1 and HTTP/2"). |
| 12 | SetBaseURL("https://postman-echo.com"), |
| 13 | TestSteps: []hrp.IStep{ |
| 14 | hrp.NewStep("HTTP/1.1 get"). |
| 15 | GET("/get"). |
| 16 | WithParams(map[string]interface{}{"foo1": "foo1", "foo2": "foo2"}). |
| 17 | WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). |
| 18 | Validate(). |
| 19 | AssertEqual("status_code", 200, "check status code"). |
| 20 | AssertEqual("proto", "HTTP/1.1", "check protocol type"). |
| 21 | AssertLengthEqual("body.args.foo1", 4, "check param foo1"), |
| 22 | hrp.NewStep("HTTP/1.1 post"). |
| 23 | POST("/post"). |
| 24 | WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). |
| 25 | WithBody(map[string]interface{}{"foo1": "foo1", "foo2": "foo2"}). |
| 26 | Validate(). |
| 27 | AssertEqual("status_code", 200, "check status code"). |
| 28 | AssertEqual("proto", "HTTP/1.1", "check protocol type"). |
| 29 | AssertLengthEqual("body.json.foo1", 4, "check body foo1"), |
| 30 | hrp.NewStep("HTTP/2 get"). |
| 31 | HTTP2(). |
| 32 | GET("/get"). |
| 33 | WithParams(map[string]interface{}{"foo1": "foo1", "foo2": "foo2"}). |
| 34 | WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). |
| 35 | Validate(). |
| 36 | AssertEqual("status_code", 200, "check status code"). |
| 37 | AssertEqual("proto", "HTTP/2.0", "check protocol type"). |
| 38 | AssertLengthEqual("body.args.foo1", 4, "check param foo1"), |
| 39 | hrp.NewStep("HTTP/2 post"). |
| 40 | HTTP2(). |
| 41 | POST("/post"). |
| 42 | WithHeaders(map[string]string{"User-Agent": "HttpRunnerPlus"}). |
| 43 | WithBody(map[string]interface{}{"foo1": "foo1", "foo2": "foo2"}). |
| 44 | Validate(). |
| 45 | AssertEqual("status_code", 200, "check status code"). |
| 46 | AssertEqual("proto", "HTTP/2.0", "check protocol type"). |
| 47 | AssertLengthEqual("body.json.foo1", 4, "check body foo1"), |
| 48 | }, |
| 49 | } |
| 50 | err := hrp.NewRunner(t).Run(testcase) |
| 51 | if err != nil { |
| 52 | t.Fatalf("run testcase error: %v", err) |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | func TestWebSocketProtocol(t *testing.T) { |
| 57 | testcase := &hrp.TestCase{ |
nothing calls this directly
no test coverage detected