Documentation
¶
Index ¶
- Constants
- func Assert(t *testing.T, r *http.Response, expected []int)
- func Body(t *testing.T, v any, m contract.Marshaler) *bytes.Reader
- func Extract[T comparable](t *testing.T, body io.Reader, u contract.Unmarshaler, field string, to *[]T, ...)
- func FailOnError(t *testing.T, err error)
- func Log(ctx context.Context, t *testing.T, logger contract.LogOperator, body io.Reader, ...) error
- func Run(t *testing.T, cfg Config, tcases []*TestCase)
- type Config
- type ExtractionOption
- type ExtractionOptions
- type HookFunc
- type LogOption
- type LogOptions
- type Request
- type RequestOption
- func WithBody(x io.Reader) RequestOption
- func WithExecutions(x uint) RequestOption
- func WithExpected(x ...int) RequestOption
- func WithHeader(k, v string) RequestOption
- func WithMethod(x string) RequestOption
- func WithMsg(x string) RequestOption
- func WithNeedsExtractedID(x bool) RequestOption
- func WithPath(x ...string) RequestOption
- func WithQuery(k string, v ...string) RequestOption
- func WithTitle(x string) RequestOption
- type RequestOptions
- type TestCase
Constants ¶
View Source
const ( MsgSent = "| Sent 🌎 |" MsgReceived = "| Received 📮 |" MsgInsertOne = "Insert One" MsgFindMany = "Find Many" MsgFindOne = "Find One" MsgReplaceOne = "Replace One" MsgActions = "Actions" MsgDeleteOne = "Delete One" )
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
func Extract[T comparable](t *testing.T, body io.Reader, u contract.Unmarshaler, field string, to *[]T, opts ExtractionOptions)
Extract extracts a field from the response body.
func FailOnError ¶
FailOnError fails the test if the error is not nil.
Types ¶
type ExtractionOption ¶
type ExtractionOption func(*ExtractionOptions)
func WithBypass ¶
func WithBypass(bypass bool) ExtractionOption
WithBypass specifies whether to bypass the extraction.
type ExtractionOptions ¶
type ExtractionOptions struct {
Bypass bool
}
func ApplyExtractionOptions ¶
func ApplyExtractionOptions(opts *ExtractionOptions, modifiers ...ExtractionOption) ExtractionOptions
type LogOption ¶
type LogOption func(*LogOptions)
func WithLoggedCollection ¶ added in v0.1.223
func WithLoggedDescription ¶ added in v0.1.223
func WithLoggedMethod ¶ added in v0.1.223
func WithLoggedMsg ¶ added in v0.1.223
func WithLoggedTitle ¶ added in v0.1.223
func WithLoggedURL ¶ added in v0.1.223
type LogOptions ¶
type LogOptions struct {
Method string
URL string
Msg string
Title string
Collection string
Description string
}
func ApplyLogOptions ¶
func ApplyLogOptions(opts *LogOptions, modifiers ...LogOption) LogOptions
type Request ¶ added in v0.1.223
type Request struct {
Opts RequestOptions
}
func NewRequest ¶ added in v0.1.223
func NewRequest(opts RequestOptions) *Request
type RequestOption ¶ added in v0.1.223
type RequestOption func(*RequestOptions)
func WithBody ¶ added in v0.1.223
func WithBody(x io.Reader) RequestOption
func WithExecutions ¶ added in v0.1.223
func WithExecutions(x uint) RequestOption
func WithExpected ¶
func WithExpected(x ...int) RequestOption
func WithHeader ¶ added in v0.1.223
func WithHeader(k, v string) RequestOption
func WithMethod ¶
func WithMethod(x string) RequestOption
func WithMsg ¶ added in v0.1.222
func WithMsg(x string) RequestOption
func WithNeedsExtractedID ¶ added in v0.1.225
func WithNeedsExtractedID(x bool) RequestOption
func WithPath ¶ added in v0.1.223
func WithPath(x ...string) RequestOption
func WithQuery ¶ added in v0.1.223
func WithQuery(k string, v ...string) RequestOption
func WithTitle ¶ added in v0.1.222
func WithTitle(x string) RequestOption
type RequestOptions ¶ added in v0.1.223
type RequestOptions struct {
Method string
Title string
Msg string
Path []string
Query map[string][]string
Expected []int
Body io.Reader
Executions uint
Header http.Header
NeedsExtractedID bool
}
func ApplyRequestOptions ¶ added in v0.1.223
func ApplyRequestOptions(opts *RequestOptions, modifiers ...RequestOption) RequestOptions
Click to show internal directories.
Click to hide internal directories.