Documentation ¶
Index ¶
- func Approximately(t *testing.T, expected time.Duration, actual time.Duration, ...)
- func ApproximatelyTime(t *testing.T, expected time.Time, actual time.Time, delta time.Duration, ...)
- func ElementsMatch[T any](t *testing.T, arrA, arrB []T, prefixes ...string)
- func Equal(t *testing.T, expected interface{}, actual interface{}, prefixes ...string)
- func Error(t *testing.T, err error, prefixes ...string)
- func ErrorIs(t *testing.T, err error, target error, prefixes ...string)
- func ErrorType(t *testing.T, err error, target error, prefixes ...string)
- func ErrorWith(t *testing.T, err error, content string, prefixes ...string)
- func ExpectCall(fn any)
- func MapHas[K comparable, V any](t *testing.T, m map[K]V, key K, val V, prefixes ...string)
- func MapMatch[K comparable, V any](t *testing.T, mapA, mapB map[K]V, prefixes ...string)
- func NilError(t *testing.T, err error, prefixes ...string)
- func NotEqual(t *testing.T, expected interface{}, actual interface{}, prefixes ...string)
- func NotNil(t *testing.T, val interface{}, prefixes ...string)
- type Counter
- type ErrorFunc
- type ResultErrorFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Approximately ¶ added in v0.3.0
func Approximately(t *testing.T, expected time.Duration, actual time.Duration, delta time.Duration, prefixes ...string)
Approximately asserts actual duration is approximately(within delta difference) equal to expected duration.
func ApproximatelyTime ¶ added in v0.11.0
func ApproximatelyTime(t *testing.T, expected time.Time, actual time.Time, delta time.Duration, prefixes ...string)
ApproximatelyTime asserts actual time.Time is approximately(within delta difference) equal to expected time.Time.
func ElementsMatch ¶
ElementsMatch asserts both slices have the same amount and equal elements. Any extra items will be listed in error log.
func ErrorWith ¶
ErrorWith asserts err does contain target content within error string representation.
func ExpectCall ¶ added in v0.8.0
func ExpectCall(fn any)
ExpectCall panics with unexpected call message for caller name if fn is nil. If fn is not a func then it will panic with invalid parameter message. Standard way to call this is:
func (m MyMock) Do(key string) error { assert.ExpectCall(m.OnDo) // if m.OnDo is nil - it will panic with accurate message return m.OnDo(key) }
func MapHas ¶
func MapHas[K comparable, V any](t *testing.T, m map[K]V, key K, val V, prefixes ...string)
MapHas asserts that map contains specified key with equal value.
func MapMatch ¶
func MapMatch[K comparable, V any](t *testing.T, mapA, mapB map[K]V, prefixes ...string)
MapMatch asserts all keys and corresponding values are applied to both map.
Types ¶
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
func Count ¶
Count returns a Counter with expected n count to be asserted. Use Inc() to mark a call. Assert() will be called on test cleanup, so it's not necessary to call it manually but recommended due to convention to not hide any test side effects.