Documentation
¶
Index ¶
- Constants
- Variables
- func Assert(t *testing.T, condition bool, messages ...string)
- func Eq(t *testing.T, want, have any, messages ...string)
- func ErrorIs(t *testing.T, want, have error, messages ...string)
- func KO(t *testing.T, err error, messages ...string)
- func MatchString(t *testing.T, pattern, s string, messages ...string)
- func OK(t *testing.T, err error, messages ...string)
- func Panics(t *testing.T, f func())
- func PanicsEq(t *testing.T, exp string, f func())
- type LogAgg
Constants ¶
const EnvNoColors = "XT_NO_COLORS"
Variables ¶
var TestHelper = (*testing.T).Helper
Functions ¶
func Assert ¶
Assert checks if condition is true. When not, messages are displayed. This is equivalent as Eq(t, true, condition, messages...).
func Eq ¶
Eq checks if the `want` value is equal to the `have` value during testing. If not equal, it triggers a test failure with optional custom `messages`.
This function uses reflection for comparison and handles nil values.
func ErrorIs ¶ added in v1.11.0
ErrorIs checks whether the provided errors are the same when not wrapping or whether the have-error is wrapped in the have-error.
func KO ¶
KO checks whether err is not nil.
Reverse of OK, and also, well, you know 💥🥊.
This could be replaced with using Eq, but since checking the error in Go is done lots, it is nicer to read in tests.
func MatchString ¶
MatchString tests whether the string s matches the regular expression pattern.
Types ¶
type LogAgg ¶ added in v1.5.0
type LogAgg struct {
// contains filtered or unexported fields
}
LogAgg is a very basic log aggregation writer which can be used to find entries. This is really just useful for tests and also not really specific to logging.