(e *httpexpect.Expect)
| 67 | } |
| 68 | |
| 69 | func testBasicHandler(e *httpexpect.Expect) { |
| 70 | e.GET("/foo") |
| 71 | e.GET("/foo").Expect() |
| 72 | e.GET("/foo").Expect().Status(http.StatusOK) |
| 73 | |
| 74 | e.GET("/foo").Expect(). |
| 75 | Status(http.StatusOK).JSON().Object().HasValue("foo", 123) |
| 76 | |
| 77 | e.PUT("/bar").WithQuery("field1", "hello").WithFormField("field2", "world"). |
| 78 | Expect(). |
| 79 | Status(http.StatusOK). |
| 80 | Form().HasValue("field1", "hello").HasValue("field2", "world") |
| 81 | |
| 82 | e.GET("/{a}/{b}", "baz", "qux"). |
| 83 | Expect(). |
| 84 | Status(http.StatusOK).JSON().Array().ConsistsOf(true, false) |
| 85 | |
| 86 | e.PUT("/{a}/{b}"). |
| 87 | WithPath("a", "baz"). |
| 88 | WithPath("b", "qux"). |
| 89 | WithJSON(map[string]string{"test": "ok"}). |
| 90 | Expect(). |
| 91 | Status(http.StatusOK).Body().IsEqual("ok") |
| 92 | |
| 93 | auth := e.Builder(func(req *httpexpect.Request) { |
| 94 | req.WithBasicAuth("john", "secret") |
| 95 | }) |
| 96 | |
| 97 | auth.PUT("/wee"). |
| 98 | Expect(). |
| 99 | Status(http.StatusOK). |
| 100 | Form().HasValue("username", "john").HasValue("password", "secret") |
| 101 | |
| 102 | e.PUT("/echo/{arg}"). |
| 103 | WithPath("arg", "test_arg"). |
| 104 | Expect(). |
| 105 | Status(http.StatusOK).Body().IsEqual("test_arg") |
| 106 | |
| 107 | e.PUT("/echo/{arg}"). |
| 108 | WithPath("arg", url.QueryEscape("some:data/thats/encoded@0.1.0")). |
| 109 | Expect(). |
| 110 | Status(http.StatusOK). |
| 111 | Body(). |
| 112 | IsEqual(url.QueryEscape("some:data/thats/encoded@0.1.0")) |
| 113 | } |
| 114 | |
| 115 | func TestE2EBasic_LiveDefault(t *testing.T) { |
| 116 | handler := createBasicHandler() |
no test coverage detected
searching dependent graphs…