MCPcopy Index your code
hub / github.com/gavv/httpexpect / testBasicHandler

Function testBasicHandler

e2e/basic_test.go:69–113  ·  view source on GitHub ↗
(e *httpexpect.Expect)

Source from the content-addressed store, hash-verified

67}
68
69func 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
115func TestE2EBasic_LiveDefault(t *testing.T) {
116 handler := createBasicHandler()

Callers 6

TestE2EBasic_LiveDefaultFunction · 0.85
TestE2EBasic_LiveConfigFunction · 0.85
TestE2EBasic_LiveTLSFunction · 0.85
TestE2EBasic_LiveLongRunFunction · 0.85
TestE2EBasic_BinderFastFunction · 0.85

Calls 15

GETMethod · 0.80
StatusMethod · 0.80
FormMethod · 0.80
WithFormFieldMethod · 0.80
WithQueryMethod · 0.80
PUTMethod · 0.80
ConsistsOfMethod · 0.80
WithJSONMethod · 0.80
WithPathMethod · 0.80
BuilderMethod · 0.80
WithBasicAuthMethod · 0.80
ExpectMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…