Documentation ¶
Overview ¶
Deprecated: This package is deprecated and will be removed in a future release. Please use the testutils package provided by github.com/mandelsoft/goutils.
Index ¶
- Constants
- func AsString(actual interface{}) (string, error)
- func AsStructure(actual interface{}, substs ...Substitutions) (interface{}, error)
- func Calling[T any](o T, err error) result[T]
- func Close(c io.Closer, msg ...interface{})
- func DeepEqual(expected interface{}) types.GomegaMatcher
- func Defer(f func() error, msg ...interface{})
- func DeferWithOffset(o int, f func() error, msg ...interface{})
- func ErrorFrom(args ...interface{}) error
- func ExpectError(values ...interface{}) types.Assertion
- func GetModuleName() (string, error)
- func GetPackagePathFromProjectRoot(i ...interface{}) (string, error)
- func GetRelativePathToProjectRoot(i ...int) (string, error)
- func MergeSubst(subst ...map[string]string) map[string]string
- func Must[T any](o T, err error) T
- func Must2[T any, V any](a T, b V, err error) (T, V)
- func Must3[T, U, V any](a T, b U, c V, err error) (T, U, V)
- func MustBeNonNil[T any](o T) T
- func MustBeSuccessful(actual ...interface{})
- func MustBeSuccessfulWithOffset(offset int, err error)
- func MustFailWithMessage(err error, msg string)
- func MustWithOffset[T any](offset int, res result[T]) T
- func NotNil[T any](o T, extra ...interface{}) T
- func PingTCPServer(address string, dur time.Duration) error
- func R[T any](o T, err error) result[T]
- func StringEqualTrimmedWithContext(expected string, subst ...Substitutions) types.GomegaMatcher
- func StringEqualWithContext(expected string, subst ...Substitutions) types.GomegaMatcher
- func StringMatchTrimmedWithContext(expected string, subst ...Substitutions) types.GomegaMatcher
- func StringMatchWithContext(expected string, subst ...Substitutions) types.GomegaMatcher
- func SubstFrom(v interface{}, prefix ...string) map[string]string
- func SubstList(values ...string) map[string]string
- func YAMLEqual(expected interface{}, subst ...Substitutions) types.GomegaMatcher
- type DeepEqualMatcher
- type StringEqualMatcher
- type Substitutions
- type YAMLEqualMatcher
Constants ¶
const GO_MOD = "go.mod"
Variables ¶
This section is empty.
Functions ¶
func AsStructure ¶ added in v0.4.1
func AsStructure(actual interface{}, substs ...Substitutions) (interface{}, error)
func DeepEqual ¶ added in v0.4.1
func DeepEqual(expected interface{}) types.GomegaMatcher
DeepEqual compares two objects and shows diff on failure.
func DeferWithOffset ¶ added in v0.3.0
func ExpectError ¶ added in v0.3.0
func GetModuleName ¶ added in v0.11.0
GetModuleName returns a go modules module name by finding and parsing the go.mod file.
func GetPackagePathFromProjectRoot ¶ added in v0.11.0
func GetRelativePathToProjectRoot ¶ added in v0.11.0
GetRelativePathToProjectRoot calculates the relative path to a go projects root directory. It therefore assumes that the project root is the directory containing the go.mod file. The optional parameter i determines how many directories the function will step up through, attempting to find a go.mod file. If it cannot find a directory with a go.mod file within i iterations, the function throws an error.
func MustBeNonNil ¶
func MustBeNonNil[T any](o T) T
func MustBeSuccessful ¶
func MustBeSuccessful(actual ...interface{})
func MustBeSuccessfulWithOffset ¶ added in v0.3.0
func MustFailWithMessage ¶
func MustWithOffset ¶
func StringEqualTrimmedWithContext ¶
func StringEqualTrimmedWithContext(expected string, subst ...Substitutions) types.GomegaMatcher
StringEqualTrimmedWithContext compares two trimmed strings and provides the complete actual value as error context. If value mappings are given, the expected string is evaluated by envsubst, first. It is an error for actual to be nil. Use BeNil() instead.
func StringEqualWithContext ¶
func StringEqualWithContext(expected string, subst ...Substitutions) types.GomegaMatcher
StringEqualWithContext compares two strings and provides the complete actual value as error context. If value mappings are given, the expected string is evaluated by envsubst, first. It is an error for actual to be nil. Use BeNil() instead.
func StringMatchTrimmedWithContext ¶ added in v0.4.1
func StringMatchTrimmedWithContext(expected string, subst ...Substitutions) types.GomegaMatcher
StringMatchTrimmedWithContext matches a trimmed string by a regular expression and provides the complete actual value as error context. If value mappings are given, the expected string is evaluated by envsubst, first. It is an error for actual to be nil. Use BeNil() instead.
func StringMatchWithContext ¶ added in v0.4.1
func StringMatchWithContext(expected string, subst ...Substitutions) types.GomegaMatcher
StringMatchWithContext matches a string by a regular expression and provides the complete actual value as error context. If value mappings are given, the expected string is evaluated by envsubst, first. It is an error for actual to be nil. Use BeNil() instead.
func YAMLEqual ¶ added in v0.4.1
func YAMLEqual(expected interface{}, subst ...Substitutions) types.GomegaMatcher
YAMLEqual compares two yaml structures. If value mappings are given, the expected string is evaluated by envsubst, first. It is an error for actual to be nil. Use BeNil() instead.
Types ¶
type DeepEqualMatcher ¶ added in v0.4.1
type DeepEqualMatcher struct {
Expected interface{}
}
func (*DeepEqualMatcher) FailureMessage ¶ added in v0.4.1
func (matcher *DeepEqualMatcher) FailureMessage(actual interface{}) (message string)
func (*DeepEqualMatcher) Match ¶ added in v0.4.1
func (matcher *DeepEqualMatcher) Match(actual interface{}) (success bool, err error)
func (*DeepEqualMatcher) NegatedFailureMessage ¶ added in v0.4.1
func (matcher *DeepEqualMatcher) NegatedFailureMessage(actual interface{}) (message string)
type StringEqualMatcher ¶
func (*StringEqualMatcher) FailureMessage ¶
func (matcher *StringEqualMatcher) FailureMessage(actual interface{}) (message string)
func (*StringEqualMatcher) Match ¶
func (matcher *StringEqualMatcher) Match(actual interface{}) (success bool, err error)
func (*StringEqualMatcher) NegatedFailureMessage ¶
func (matcher *StringEqualMatcher) NegatedFailureMessage(actual interface{}) (message string)
type Substitutions ¶ added in v0.4.1
type YAMLEqualMatcher ¶ added in v0.4.1
type YAMLEqualMatcher struct {
Expected interface{}
}
func (*YAMLEqualMatcher) FailureMessage ¶ added in v0.4.1
func (matcher *YAMLEqualMatcher) FailureMessage(actual interface{}) (message string)
func (*YAMLEqualMatcher) Match ¶ added in v0.4.1
func (matcher *YAMLEqualMatcher) Match(actual interface{}) (success bool, err error)
func (*YAMLEqualMatcher) NegatedFailureMessage ¶ added in v0.4.1
func (matcher *YAMLEqualMatcher) NegatedFailureMessage(actual interface{}) (message string)