Documentation
¶
Overview ¶
Package webtest import some useful method to perfome assertion for testing package.
Index ¶
- func Body(t *testing.T, expected string, resp *http.Response, msg ...any)
- func BodyContains(t *testing.T, expected string, resp *http.Response, msg ...any)
- func BodyContainsStr(t *testing.T, expected string, body []byte, msg ...any)
- func BodyDiffere(t *testing.T, expected string, resp *http.Response)
- func BodyStr(t *testing.T, expected string, body []byte, msg ...any)
- func DeleteAndTestAPI(t *testing.T, url string, handler HandlerForTest)
- func FetchBody(t *testing.T, resp *http.Response) string
- func Header(t *testing.T, key, val string, resp *http.Response) bool
- func Headers(t *testing.T, resp *http.Response, kv ...[2]string) bool
- func HeadersExact(t *testing.T, resp *http.Response, kv ...[2]string) bool
- func PushAndTestAPI(t *testing.T, path string, content []byte, handler HandlerForTest, ...)
- func RequestAndTestAPI(t *testing.T, url string, handler HandlerForTest)
- func StatusCode(t *testing.T, expected int, resp *http.Response, msg ...any)
- type HandlerForTest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BodyContains ¶ added in v1.2.2
func BodyContainsStr ¶ added in v1.3.1
func BodyDiffere ¶
BodyDiffere fetch and assert that the body of the http.Response differ than expected
func BodyStr ¶ added in v1.3.1
Body fetch and assert that the body of the http.Response is the same than expected
func DeleteAndTestAPI ¶
func DeleteAndTestAPI(t *testing.T, url string, handler HandlerForTest)
DeleteAndTestAPI run a DELETE request before running the test handler.
func HeadersExact ¶ added in v1.3.1
Headers assert value of the given header key:vak in the htt.Response param.
func PushAndTestAPI ¶
func PushAndTestAPI(t *testing.T, path string, content []byte, handler HandlerForTest, headers ...[2]string)
PushAndTestAPI post to an API then run the test handler. The sub method try to send an `application/json` encoded content
func RequestAndTestAPI ¶
func RequestAndTestAPI(t *testing.T, url string, handler HandlerForTest)
RequestAndTestAPI request an API then run the test handler.
Types ¶
Click to show internal directories.
Click to hide internal directories.