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 ClearExtracted()
- func Extract[T comparable](ctx context.Context, opts ExtractionOptions[T])
- func FailOnError(t *testing.T, err error)
- func GetExtracted() string
- func Log(ctx context.Context, t *testing.T, d LogDependencies, opts LogOptions) error
- func MultipartBody(ctx context.Context, opts MultipartBodyOptions) (io.Reader, string)
- func MustExtracted(t *testing.T) 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 WithReader[T comparable](x contract.Reader) 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 WithBodyFunc(x func() 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 ( TEST = "TEST" TestEmail = "test@fabriktor.com" TestPhone = "+14508474524" TestUsername = "Bobino_94" TestFirstName = "Bobino" TestLastName = "Bazinet" TestVerificationCode = "183423" TestUID = "1234567_OMEWOIFIWMWFTOYONIAGEM890" TestProfane = "dick" TestTag = "tag" TestItemName = "item" TestPriceUSD = 1255 TestDescription = "this is a description" TestQuantifier = "box" )
View Source
const ( MsgSent = "[SENT 🌎]" MsgReceived = "[RECEIVED 📮]" MsgInsertOne = "[INSERT ONE]" MsgUpsertOne = "[UPSERT 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 ClearExtracted ¶
func ClearExtracted()
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 GetExtracted ¶
func GetExtracted() string
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 ¶
MultipartBody returns a multipart reader built from file paths in the test filesystem and a content type.
func MustExtracted ¶
Types ¶
type Config ¶
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)
SleepBetween time.Duration
}
func (*Config) GetAuthHeader ¶
func (*Config) SetHeaderKeyUserID ¶
func (*Config) SetOIDCToken ¶
type ExtractionOption ¶
type ExtractionOption[T comparable] = contract.Opt[ExtractionOptions[T]]
func WithBypass ¶
func WithBypass[T comparable](x bool) ExtractionOption[T]
func WithExtractionBody ¶
func WithExtractionBody[T comparable](x io.Reader) ExtractionOption[T]
func WithField ¶
func WithField[T comparable](x string) ExtractionOption[T]
func WithMarshaler ¶
func WithMarshaler[T comparable](x contract.Marshaler) ExtractionOption[T]
func WithReader ¶
func WithReader[T comparable](x contract.Reader) ExtractionOption[T]
func WithT ¶
func WithT[T comparable](x *testing.T) ExtractionOption[T]
func WithTo ¶
func WithTo[T comparable](x *[]T) ExtractionOption[T]
func WithUnmarshaler ¶
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 R contract.Reader 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 ¶
func (o *ExtractionOptions[T]) Validate() error
type LogDependencies ¶
type LogOption ¶
type LogOption = contract.Opt[LogOptions]
func WithLoggedCollection ¶
func WithLoggedDescription ¶
func WithLoggedMethod ¶
func WithLoggedMsg ¶
func WithLoggedTitle ¶
func WithLoggedURL ¶
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 ¶
type MultipartBodyOptions struct {
T *testing.T
FS fs.ReadFileFS
FSO contract.FSysOperator
M contract.MultipartOperator
Paths []string
}
type Request ¶
type Request struct {
Opts RequestOptions
}
func NewRequest ¶
func NewRequest(opts RequestOptions) *Request
type RequestOption ¶
type RequestOption = contract.Opt[RequestOptions]
func WithBody ¶
func WithBody(x io.Reader) RequestOption
func WithBodyFunc ¶
func WithBodyFunc(x func() io.Reader) RequestOption
func WithExecutions ¶
func WithExecutions(x uint) RequestOption
func WithExpected ¶
func WithExpected(x ...int) RequestOption
func WithExtractField ¶
func WithExtractField() RequestOption
func WithHeader ¶
func WithHeader(x http.Header) RequestOption
func WithHeaderAdd ¶
func WithHeaderAdd(k, v string) RequestOption
func WithHeaderSet ¶
func WithHeaderSet(k, v string) RequestOption
func WithMethod ¶
func WithMethod(x string) RequestOption
func WithMsg ¶
func WithMsg(x string) RequestOption
func WithMultipartBody ¶
func WithMultipartBody(x io.Reader, ct string) RequestOption
func WithPath ¶
func WithPath(x ...string) RequestOption
func WithQuery ¶
func WithQuery(k string, v ...string) RequestOption
func WithTimeout ¶
func WithTimeout(x time.Duration) RequestOption
func WithTitle ¶
func WithTitle(x string) RequestOption
func WithUseExtracted ¶
func WithUseExtracted() RequestOption
type RequestOptions ¶
type RequestOptions struct {
Method string
Title string
Msg string
Path []string
Query map[string][]string
Expected []int
Body io.Reader
BodyFunc func() io.Reader
Executions uint
Header http.Header
ExtractField bool
UseExtracted bool
Timeout time.Duration
}
func ApplyRequestOptions ¶
func ApplyRequestOptions(opts *RequestOptions, modifiers ...RequestOption) RequestOptions
Click to show internal directories.
Click to hide internal directories.