Documentation ¶
Overview ¶
Package psi contains helpers that extends gomega library Name psi stands for previous letter from Omega (as we want to have a name that is close to gomega, but not to be a gomega)
Package psi is considered as internal package to be used only inside `be` It's a core functionality that upgrades any matcher to be a `be` matcher Also it contains some core matchers and upgraded things from `gomega/gcustom` package
Index ¶
- Variables
- func AsMatchFunc(m any) func(any) (bool, error)
- func AsMatcher(m any) types.BeMatcher
- func FromGomega(omega types.GomegaMatcher, messagePrefixArg ...string) types.BeMatcher
- func FromGomock(m types.GomockMatcher) types.BeMatcher
- func IsMatchFunc(m any) bool
- func IsMatcher(a any) bool
- func IsTransformFunc(v any) bool
- func Psi(args ...any) types.BeMatcher
- func WithFallibleTransform(transform any, matcher gomega.OmegaMatcher) types.BeMatcher
- type DiveMatcher
- type DiveMode
- type MixinMatcherGomock
- type TransformError
- type TransformErrorMatcher
Constants ¶
This section is empty.
Variables ¶
var ( // ExpectedStr2LinesRegex matches first 2 lines of standard gomega failure message ExpectedStr2LinesRegex = regexp.MustCompile(`Expected\n.*\n`) )
Functions ¶
func FromGomega ¶
func FromGomega(omega types.GomegaMatcher, messagePrefixArg ...string) types.BeMatcher
func FromGomock ¶
func FromGomock(m types.GomockMatcher) types.BeMatcher
func IsMatchFunc ¶ added in v0.2.0
func IsTransformFunc ¶
IsTransformFunc checks if given thing is a Gomega-compatible transform For v to be a transform it must be a function of one parameter that returns one value and an optional error
func WithFallibleTransform ¶
func WithFallibleTransform(transform any, matcher gomega.OmegaMatcher) types.BeMatcher
WithFallibleTransform creates a gomega transform matcher that can nicely handle failures Also it allows to have nil matcher, meaning that we're OK unless transform failed
Types ¶
type DiveMatcher ¶ added in v0.2.0
type DiveMatcher struct { *MixinMatcherGomock // contains filtered or unexported fields }
func NewDiveMatcher ¶ added in v0.2.0
func NewDiveMatcher(matcher any, mode DiveMode) *DiveMatcher
func (*DiveMatcher) FailureMessage ¶ added in v0.2.0
func (dm *DiveMatcher) FailureMessage(actual any) string
func (*DiveMatcher) Match ¶ added in v0.2.0
func (dm *DiveMatcher) Match(actual interface{}) (bool, error)
func (*DiveMatcher) NegatedFailureMessage ¶ added in v0.2.0
func (dm *DiveMatcher) NegatedFailureMessage(actual any) string
type MixinMatcherGomock ¶
type MixinMatcherGomock struct {
// contains filtered or unexported fields
}
MixinMatcherGomock should be used for embedding to create a matcher that fits Gomock interface
func NewMixinMatcherGomock ¶
func NewMixinMatcherGomock(Ω types.GomegaMatcher, messagePrefixArg ...string) *MixinMatcherGomock
func (*MixinMatcherGomock) Matches ¶
func (igm *MixinMatcherGomock) Matches(v any) bool
func (*MixinMatcherGomock) String ¶
func (igm *MixinMatcherGomock) String() string
type TransformError ¶
type TransformError struct {
// contains filtered or unexported fields
}
TransformError is used to store error + actual value which caused the error
func NewTransformError ¶
func NewTransformError(err error, actual any) *TransformError
func (*TransformError) Actual ¶
func (terr *TransformError) Actual() any
type TransformErrorMatcher ¶
type TransformErrorMatcher struct {
// contains filtered or unexported fields
}
TransformErrorMatcher is actually a matcher
func WithTransformError ¶
func WithTransformError() *TransformErrorMatcher
func (*TransformErrorMatcher) FailureMessage ¶
func (matcher *TransformErrorMatcher) FailureMessage(actual any) string
func (*TransformErrorMatcher) Match ¶
func (matcher *TransformErrorMatcher) Match(actual any) (success bool, err error)
func (*TransformErrorMatcher) NegatedFailureMessage ¶
func (matcher *TransformErrorMatcher) NegatedFailureMessage(actual any) string