Documentation
¶
Index ¶
- Constants
- func Assert(t *testing.T, r *http.Response, expected []int)
- func Body(ctx context.Context, t *testing.T, v any, m contract.Marshaler) io.Reader
- func Extract[T comparable](ctx context.Context, opts ExtractionOptions[T])
- func FailOnError(t *testing.T, err error)
- func Log(ctx context.Context, t *testing.T, d LogDependencies, opts LogOptions) error
- func MultipartBody(ctx context.Context, opts MultipartBodyOptions) (io.Reader, string)
- func Run(t *testing.T, cfg Config, tcases []*TestCase)
- type Config
- type ExtractionOption
- func WithBypass[T comparable](x bool) ExtractionOption[T]
- func WithExtractionBody[T comparable](x io.Reader) ExtractionOption[T]
- func WithField[T comparable](x string) ExtractionOption[T]
- func WithMarshaler[T comparable](x contract.Marshaler) ExtractionOption[T]
- func WithT[T comparable](x *testing.T) ExtractionOption[T]
- func WithTo[T comparable](x *[]T) ExtractionOption[T]
- func WithUnmarshaler[T comparable](x contract.Unmarshaler) ExtractionOption[T]
- type ExtractionOptions
- type HookFunc
- type Keys
- type LogDependencies
- type LogOption
- type LogOptions
- type MultipartBodyOptions
- type Request
- type RequestOption
- func WithBody(x io.Reader) RequestOption
- func WithExecutions(x uint) RequestOption
- func WithExpected(x ...int) RequestOption
- func WithExtractField() RequestOption
- func WithHeader(x http.Header) RequestOption
- func WithHeaderAdd(k, v string) RequestOption
- func WithHeaderSet(k, v string) RequestOption
- func WithMethod(x string) RequestOption
- func WithMsg(x string) RequestOption
- func WithMultipartBody(x io.Reader, ct string) RequestOption
- func WithPath(x ...string) RequestOption
- func WithQuery(k string, v ...string) RequestOption
- func WithTimeout(x time.Duration) RequestOption
- func WithTitle(x string) RequestOption
- func WithUseExtracted() RequestOption
- type RequestOptions
- type TestCase
- type TokenSet
Constants ¶
View Source
const ( TestEmail = "test@fabriktor.com" TestPhone = "+14508474524" TestUsername = "Bobino_94" TestFirstName = "Bobino" TestLastName = "Bazinet" TestVerificationCode = "183423" TestUID = "1234567_OMEWOIFIWMWFTOYONIAGEM890" TestProfane = "dick" )
View Source
const ( MsgSent = "[SENT 🌎]" MsgReceived = "[RECEIVED 📮]" MsgInsertOne = "[INSERT ONE]" MsgFindMany = "[FIND MANY]" MsgFindOne = "[FIND ONE]" MsgReplaceOne = "[REPLACE ONE]" MsgActions = "[ACTIONS]" MsgDeleteOne = "[DELETE ONE]" )
View Source
const ( TokenTypeFirebase = "firebase" TokenTypeOIDC = "oidc" )
Variables ¶
This section is empty.
Functions ¶
func Extract ¶
func Extract[T comparable](ctx context.Context, opts ExtractionOptions[T])
Extract finds a field in the response body and appends its value to opts.To.
func FailOnError ¶
FailOnError fails the test if the error is not nil.
func Log ¶
func Log(ctx context.Context, t *testing.T, d LogDependencies, opts LogOptions) error
Log creates a detailed log entry for integration tests requests and responses.
func MultipartBody ¶ added in v0.1.516
MultipartBody returns a multipart reader built from file paths in the test filesystem and a content type.
Types ¶
type Config ¶ added in v0.1.223
type Config struct {
Ctx context.Context
BaseURL string
T *toolbox.Toolbox
Extract map[string]string
Field string
Token TokenSet
K Keys
BeforeEach HookFunc
AfterEach HookFunc
AfterTestCase func(Config, *TestCase)
SleepBetweenCases time.Duration
}
func (*Config) GetAuthHeader ¶ added in v0.1.354
func (*Config) SetHeaderKeyUserID ¶ added in v0.1.435
func (*Config) SetOIDCToken ¶ added in v0.1.353
type ExtractionOption ¶
type ExtractionOption[T comparable] func(*ExtractionOptions[T])
func WithBypass ¶
func WithBypass[T comparable](x bool) ExtractionOption[T]
func WithExtractionBody ¶ added in v0.1.281
func WithExtractionBody[T comparable](x io.Reader) ExtractionOption[T]
func WithField ¶ added in v0.1.281
func WithField[T comparable](x string) ExtractionOption[T]
func WithMarshaler ¶ added in v0.1.314
func WithMarshaler[T comparable](x contract.Marshaler) ExtractionOption[T]
func WithT ¶ added in v0.1.281
func WithT[T comparable](x *testing.T) ExtractionOption[T]
func WithTo ¶ added in v0.1.281
func WithTo[T comparable](x *[]T) ExtractionOption[T]
func WithUnmarshaler ¶ added in v0.1.281
func WithUnmarshaler[T comparable](x contract.Unmarshaler) ExtractionOption[T]
type ExtractionOptions ¶
type ExtractionOptions[T comparable] struct { T *testing.T Body io.Reader Field string To *[]T U contract.Unmarshaler M contract.Marshaler Bypass bool }
ExtractionOptions contains all parameters for a structured field extraction.
func ApplyExtractionOptions ¶
func ApplyExtractionOptions[T comparable](opts *ExtractionOptions[T], modifiers ...ExtractionOption[T]) ExtractionOptions[T]
func (*ExtractionOptions[T]) Validate ¶ added in v0.1.281
func (o *ExtractionOptions[T]) Validate() error
type LogDependencies ¶ added in v0.1.302
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 MultipartBodyOptions ¶ added in v0.1.516
type MultipartBodyOptions struct {
T *testing.T
FS fs.ReadFileFS
FSO contract.FSysOperator
M contract.MultipartOperator
Paths []string
}
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 WithExtractField ¶ added in v0.1.331
func WithExtractField() RequestOption
func WithHeader ¶ added in v0.1.223
func WithHeader(x http.Header) RequestOption
func WithHeaderAdd ¶ added in v0.1.290
func WithHeaderAdd(k, v string) RequestOption
func WithHeaderSet ¶ added in v0.1.290
func WithHeaderSet(k, v string) RequestOption
func WithMethod ¶
func WithMethod(x string) RequestOption
func WithMsg ¶ added in v0.1.222
func WithMsg(x string) RequestOption
func WithMultipartBody ¶ added in v0.1.519
func WithMultipartBody(x io.Reader, ct string) 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 WithTimeout ¶ added in v0.1.552
func WithTimeout(x time.Duration) RequestOption
func WithTitle ¶ added in v0.1.222
func WithTitle(x string) RequestOption
func WithUseExtracted ¶ added in v0.1.331
func WithUseExtracted() 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
ExtractField bool
UseExtracted bool
Timeout time.Duration
}
func ApplyRequestOptions ¶ added in v0.1.223
func ApplyRequestOptions(opts *RequestOptions, modifiers ...RequestOption) RequestOptions
Click to show internal directories.
Click to hide internal directories.