modulepackage
2.15.2
Repository: https://github.com/iris-contrib/httpexpect.git
Documentation: pkg.go.dev
# README
HTTP Expect
Test functionality behind iris/httptest forked by gavv/httpexpect.
# Functions
Default returns a new Expect instance with default config.
Deprecated: use Default instead.
NewArray returns a new Array instance.
NewArrayC returns a new Array instance with config.
NewAssertReporter returns a new AssertReporter object.
NewBinder returns a new Binder given a http.Handler.
NewBoolean returns a new Boolean instance.
NewBooleanC returns a new Boolean instance with config.
NewCompactPrinter returns a new CompactPrinter given a logger.
NewCookie returns a new Cookie instance.
NewCookieC returns a new Cookie instance with config.
NewCookieJar returns a new http.CookieJar.
NewCurlPrinter returns a new CurlPrinter given a logger.
NewDateTime returns a new DateTime instance.
NewDateTimeC returns a new DateTime instance with config.
NewDebugPrinter returns a new DebugPrinter given a logger and body flag.
NewDuration returns a new Duration instance.
NewDurationC returns a new Duration instance with config.
NewEnvironment returns a new Environment.
NewEnvironmentC returns a new Environment with config.
NewFatalReporter returns a new FatalReporter object.
Deprecated: use NewCookieJar instead.
NewMatch returns a new Match instance.
NewMatchC returns a new Match instance with config.
NewNumber returns a new Number instance.
NewNumberC returns a new Number instance with config.
NewObject returns a new Object instance.
NewObjectC returns a new Object instance with config.
NewPanicReporter returns a new PanicReporter object.
Deprecated: use NewRequestC instead.
NewRequestC returns a new Request instance.
NewRequireReporter returns a new RequireReporter object.
NewResponse returns a new Response instance.
NewResponse returns a new Response instance with config.
NewString returns a new String instance.
NewStringC returns a new String instance with config.
NewValue returns a new Value instance.
NewValueC returns a new Value instance with config.
Deprecated: use NewWebsocketC instead.
NewWebsocketC returns a new Websocket instance.
NewWebsocketDialer produces new websocket.Dialer which dials to bound http.Handler without creating a real net.Conn.
NewWebsocketMessage returns a new WebsocketMessage instance.
NewWebsocketMessageC returns a new WebsocketMessage instance with config.
WithConfig returns a new Expect instance with custom config.
# Constants
Check expression: [Actual] belongs to list [Expected] [Expected] stores AssertionList with allowed values.
Check expression: [Actual] contains element [Expected].
Check expression: [Actual] contains key [Expected].
Check expression: [Actual] contains subset [Expected].
Check expression: [Actual] is empty.
Check expression: [Actual] is equal to [Expected] If [Delta] is set, it specifies allowed difference between values.
Check expression: [Actual] >= [Expected].
Check expression: [Actual] > [Expected].
Check expression: [Actual] belongs to inclusive range [Expected] [Expected] stores AssertionRange with Min and Max values.
Check expression: [Actual] <= [Expected].
Check expression: [Actual] < [Expected].
Check expression: [Actual] matches format [Expected] [Expected] stores expected format or format list (AssertionList).
Check expression: [Actual] matches json path [Expected] [Expected] stores a string with json path.
Check expression: [Actual] matches regex [Expected] [Expected] stores a string with regular expression.
Check expression: [Actual] matches json schema [Expected] [Expected] stores map with parsed schema or string with schema uri.
Check expression: [Actual] is nil.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
go:generate stringer -type=AssertionType.
Check if the operation succeeded.
Check expression: [Actual] has appropriate type.
Check if the invocation is correct.
Check expression: [Actual] has valid value.
Unconditionally enable colors.
Automatically enable colors if ALL of the following is true: - stdout is a tty / console - AssertionHandler is known to output to testing.T - testing.Verbose() is true
Colors are forcibly enabled if FORCE_COLOR environment variable is set to a positive integer.
Unconditionally disable colors.
Separate using apostrophe.
Separate using comma.
Do not separate.
Separate using underscore.
DontFollowRedirects forbids following any redirects.
DontRetry disables retrying at all.
Print floats in scientific notation for large exponents, otherwise print in decimal notation.
Always print floats in decimal notation.
Always print floats in scientific notation.
FollowAllRedirects allows following any redirects, including those which require resending body.
FollowRedirectsWithoutBody allows following only redirects which don't require resending body.
RetryAllErrors enables retrying of any error or 4xx/5xx status code.
Deprecated: use RetryTimeoutAndServerErrors instead.
Deprecated: use RetryTimeoutErrors instead.
RetryTimeoutAndServerErrors enables retrying of network timeout errors, as well as 5xx status codes.
RetryTimeoutErrors enables retrying of timeout errors.
This assertion failure should mark current test as failed.
This assertion failure is informational only, it can be logged, but should not cause test failure.
Compact format.
Don't print stacktrace.
Standard, verbose format.
Status1xx defines "Informational" status codes.
Status2xx defines "Success" status codes.
Status3xx defines "Redirection" status codes.
Status4xx defines "Client Error" status codes.
Status5xx defines "Server Error" status codes.
# Structs
Array provides methods to inspect attached []interface{} object (Go representation of JSON array).
AssertionContext provides context where the assetion happened.
AssertionFailure provides detailed information about failed assertion.
AssertionRange holds inclusive range for allowed values.
AssertionValue holds expected or actual value.
AssertReporter implements Reporter interface using `testify/assert' package.
Binder implements networkless http.RoundTripper attached directly to http.Handler.
Boolean provides methods to inspect attached bool value (Go representation of JSON boolean).
CompactPrinter implements Printer.
Config contains various settings.
ContentOpts define parameters for matching the response content parameters.
Cookie provides methods to inspect attached http.Cookie value.
CurlPrinter implements Printer.
DateTime provides methods to inspect attached time.Time value.
DebugPrinter implements Printer and WebsocketPrinter.
DefaultAssertionHandler is default implementation for AssertionHandler.
DefaultFormatter is the default Formatter implementation.
DefaultRequestFactory is the default RequestFactory implementation which just calls http.NewRequest.
Duration provides methods to inspect attached time.Duration value.
Environment provides a container for arbitrary data shared between tests.
Expect is a toplevel object that contains user Config and allows to construct Request objects.
FatalReporter is a struct that implements the Reporter interface and calls t.Fatalf() when a test fails.
FormatData defines data passed to template engine when DefaultFormatter formats assertion.
Match provides methods to inspect attached regexp match results.
Number provides methods to inspect attached float64 value (Go representation of JSON number).
Object provides methods to inspect attached map[string]interface{} object (Go representation of JSON object).
PanicReporter is a struct that implements the Reporter interface and panics when a test fails.
Request provides methods to incrementally build http.Request object, send it, and receive response.
RequireReporter implements Reporter interface using `testify/require' package.
Response provides methods to inspect attached http.Response object.
Stacktrace entry.
String provides methods to inspect attached string value (Go representation of JSON string).
Value provides methods to inspect attached interface{} object (Go representation of arbitrary JSON value) and cast it to concrete type.
Websocket provides methods to read from, write into and close WebSocket connection.
WebsocketMessage provides methods to inspect message read from WebSocket connection.
# Interfaces
AssertionHandler takes care of formatting and reporting test Failure or Success.
Client is used to send http.Request and receive http.Response.
Formatter is used to format assertion messages into strings.
Logger is used as output backend for Printer.
Deprecated: use TestingTB instead.
Printer is used to print requests and responses.
Reporter is used to report failures.
RequestFactory is used to create all http.Request objects.
TestingTB is a subset of testing.TB interface used by httpexpect.
WebsocketConn is used by Websocket to communicate with actual WebSocket connection.
WebsocketDialer is used to establish websocket.Conn and receive http.Response of handshake result.
WebsocketPrinter is used to print writes and reads of WebSocket connection.
# Type aliases
AssertionList holds list of allowed values.
AssertionSeverity defines how assertion failure should be treated.
AssertionType defines type of performed assertion.
ClientFunc is an adapter that allows a function to be used as the Client
Example:
e := httpexpect.WithConfig(httpexpect.Config{ Client: httpextect.ClientFunc( func(req *http.Request) (*http.Response, error) { // client code here }), }).
ColorMode defines how the text color is enabled.
DigitSeparator defines the separator used to format integers and floats.
FloatFormat defines the format in which all floats are printed.
LoggerFunc is an adapter that allows a function to be used as the Logger
Example:
e := httpexpect.WithConfig(httpexpect.Config{ Printers: []httpexpect.Printer{ httpexpect.NewCompactPrinter( httpextect.LoggerFunc( func(fmt string, args ...interface{}) { // logger code here })), }, }).
RedirectPolicy defines how redirection responses are handled.
ReporterFunc is an adapter that allows a function to be used as the Reporter
Example:
e := httpexpect.WithConfig(httpexpect.Config{ Reporter: httpextect.ReporterFunc( func(message string, args ...interface{}) { // reporter code here }), }).
RequestFactoryFunc is an adapter that allows a function to be used as the RequestFactory
Example:
e := httpexpect.WithConfig(httpexpect.Config{ RequestFactory: httpextect.RequestFactoryFunc( func(method string, url string, body io.Reader) (*http.Request, error) { // factory code here }), }).
RetryPolicy defines how failed requests are retried.
StacktraceMode defines the format of stacktrace.
StatusRange is enum for response status ranges.
WebsocketDialerFunc is an adapter that allows a function to be used as the WebsocketDialer
Example:
e := httpexpect.WithConfig(httpexpect.Config{ WebsocketDialer: httpextect.WebsocketDialerFunc( func(url string, reqH http.Header) (*websocket.Conn, *http.Response, error) { // dialer code here }), }).