package testttp
import "github.com/influxdata/influxdb/pkg/testttp"
Index ¶
- type Req
- func Delete(t testing.TB, addr string) *Req
- func Get(t testing.TB, addr string) *Req
- func HTTP(t testing.TB, method, addr string, body io.Reader) *Req
- func Patch(t testing.TB, addr string, body io.Reader) *Req
- func PatchJSON(t testing.TB, addr string, v interface{}) *Req
- func Post(t testing.TB, addr string, body io.Reader) *Req
- func PostJSON(t testing.TB, addr string, v interface{}) *Req
- func Put(t testing.TB, addr string, body io.Reader) *Req
- func PutJSON(t testing.TB, addr string, v interface{}) *Req
- func (r *Req) Do(handler http.Handler) *Resp
- func (r *Req) Headers(k, v string, rest ...string) *Req
- func (r *Req) SetFormValue(k, v string) *Req
- func (r *Req) WithCtx(ctx context.Context) *Req
- func (r *Req) WrapCtx(fn func(ctx context.Context) context.Context) *Req
- type Resp
Types ¶
type Req ¶
type Req struct {
// contains filtered or unexported fields
}
Req is a request builder.
func Delete ¶
Delete creates a DELETE request.
func Get ¶
Get creates a GET request.
func HTTP ¶
HTTP runs creates a request for an http call.
func Patch ¶
Patch creates a PATCH request.
func PatchJSON ¶
PatchJSON creates a PATCH request with a json encoded body.
func Post ¶
Post creates a POST request.
func PostJSON ¶
PostJSON returns a POST request with a json encoded body.
func Put ¶
Put creates a PUT request.
func PutJSON ¶
PutJSON creates a PUT request with a json encoded body.
func (*Req) Do ¶
Do runs the request against the provided handler.
func (*Req) Headers ¶
Headers allows the user to set headers on the http request.
func (*Req) SetFormValue ¶
func (*Req) WithCtx ¶
WithCtx sets the ctx on the request.
func (*Req) WrapCtx ¶
WrapCtx provides means to wrap a request context. This is useful for stuffing in the auth stuffs that are required at times.
type Resp ¶
type Resp struct { Req *http.Request Rec *httptest.ResponseRecorder // contains filtered or unexported fields }
Resp is a http recorder wrapper.
func (*Resp) Debug ¶
Debug sets the debugger. If true, the debugger will print the body of the response when the expected status is not received.
func (*Resp) Expect ¶
Expect allows the assertions against the raw Resp.
func (*Resp) ExpectBody ¶
ExpectBody provides an assertion against the recorder body.
func (*Resp) ExpectHeader ¶
ExpectHeader asserts that the header is in the recorder.
func (*Resp) ExpectHeaders ¶
ExpectHeaders asserts that multiple headers with values exist in the recorder.
func (*Resp) ExpectStatus ¶
ExpectStatus compares the expected status code against the recorded status code.
Source Files ¶
- Version
- v1.12.0 (latest)
- Published
- Apr 8, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 2 days ago –
Tools for package owners.