assert

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 4 Imported by: 0

README

assert

assert lets you use github.com/stretchr/testify/assert outside of tests.

The idea is to spread assertion code all over your code base while developing and have the assertions panic, if they fail.

This allows for fast development.

For production code, you compile with

go build -tags production

and the assertion code will be optimized away.

All methods of github.com/stretchr/testify/assert#Assertions are copied as toplevel functions of this packages. They will just return true, when your program is compiled with the production flag and panic, if an assertion fails otherwise.

Documentation

For documentation of the functions see https://pkg.go.dev/github.com/stretchr/testify/assert#Assertions

License

MIT (see LICENSE file)

Documentation

Overview

Package assert lets you use `github.com/stretchr/testify/assert` outside of tests.

The idea is to spread assertion code all over your code base while developing and have the assertions panic, if they fail.

This allows for fast development.

For production code, you compile with

go build -tags production

and the assertion code will be optimized away.

All methods of `github.com/stretchr/testify/assert#Assertions` are copied as toplevel functions of this packages. They will just return true, when your program is compiled with the `production` flag and panic, if an assertion fails otherwise.

For documentation of the functions see https://pkg.go.dev/github.com/stretchr/testify/assert#Assertions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Condition

func Condition(comp assert.Comparison, msgAndArgs ...interface{}) bool

func Conditionf

func Conditionf(comp assert.Comparison, msg string, args ...interface{}) bool

func Contains

func Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool

func Containsf

func Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool

func DirExists

func DirExists(path string, msgAndArgs ...interface{}) bool

func DirExistsf

func DirExistsf(path string, msg string, args ...interface{}) bool

func ElementsMatch

func ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool

func ElementsMatchf

func ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool

func Empty

func Empty(object interface{}, msgAndArgs ...interface{}) bool

func Emptyf

func Emptyf(object interface{}, msg string, args ...interface{}) bool

func Equal

func Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool

func EqualError

func EqualError(theError error, errString string, msgAndArgs ...interface{}) bool

func EqualErrorf

func EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool

func EqualExportedValues

func EqualExportedValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool

func EqualExportedValuesf

func EqualExportedValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func EqualValues

func EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool

func EqualValuesf

func EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func Equalf

func Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func Error

func Error(err error, msgAndArgs ...interface{}) bool

func ErrorAs

func ErrorAs(err error, target interface{}, msgAndArgs ...interface{}) bool

func ErrorAsf

func ErrorAsf(err error, target interface{}, msg string, args ...interface{}) bool

func ErrorContains

func ErrorContains(theError error, contains string, msgAndArgs ...interface{}) bool

func ErrorContainsf

func ErrorContainsf(theError error, contains string, msg string, args ...interface{}) bool

func ErrorIs

func ErrorIs(err error, target error, msgAndArgs ...interface{}) bool

func ErrorIsf

func ErrorIsf(err error, target error, msg string, args ...interface{}) bool

func Errorf

func Errorf(err error, msg string, args ...interface{}) bool

func Eventually

func Eventually(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool

func EventuallyWithT

func EventuallyWithT(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool

func EventuallyWithTf

func EventuallyWithTf(condition func(collect *assert.CollectT), waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool

func Eventuallyf

func Eventuallyf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool

func Exactly

func Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool

func Exactlyf

func Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func Fail

func Fail(failureMessage string, msgAndArgs ...interface{}) bool

func FailNow

func FailNow(failureMessage string, msgAndArgs ...interface{}) bool

func FailNowf

func FailNowf(failureMessage string, msg string, args ...interface{}) bool

func Failf

func Failf(failureMessage string, msg string, args ...interface{}) bool

func False

func False(value bool, msgAndArgs ...interface{}) bool

func Falsef

func Falsef(value bool, msg string, args ...interface{}) bool

func FileExists

func FileExists(path string, msgAndArgs ...interface{}) bool

func FileExistsf

func FileExistsf(path string, msg string, args ...interface{}) bool

func Greater

func Greater(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool

func GreaterOrEqualf

func GreaterOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool

func Greaterf

func Greaterf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool

func HTTPBodyContains

func HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool

func HTTPBodyContainsf

func HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool

func HTTPBodyNotContains

func HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool

func HTTPBodyNotContainsf

func HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool

func HTTPError

func HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool

func HTTPErrorf

func HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool

func HTTPRedirect

func HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool

func HTTPRedirectf

func HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool

func HTTPStatusCode

func HTTPStatusCode(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool

func HTTPStatusCodef

func HTTPStatusCodef(handler http.HandlerFunc, method string, url string, values url.Values, statuscode int, msg string, args ...interface{}) bool

func HTTPSuccess

func HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool

func HTTPSuccessf

func HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool

func Implements

func Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool

func Implementsf

func Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool

func InDelta

func InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool

func InDeltaMapValues

func InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool

func InDeltaMapValuesf

func InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool

func InDeltaSlice

func InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool

func InDeltaSlicef

func InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool

func InDeltaf

func InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool

func InEpsilon

func InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool

func InEpsilonSlice

func InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool

func InEpsilonSlicef

func InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool

func InEpsilonf

func InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool

func IsDecreasing

func IsDecreasing(object interface{}, msgAndArgs ...interface{}) bool

func IsDecreasingf

func IsDecreasingf(object interface{}, msg string, args ...interface{}) bool

func IsIncreasing

func IsIncreasing(object interface{}, msgAndArgs ...interface{}) bool

func IsIncreasingf

func IsIncreasingf(object interface{}, msg string, args ...interface{}) bool

func IsNonDecreasing

func IsNonDecreasing(object interface{}, msgAndArgs ...interface{}) bool

func IsNonDecreasingf

func IsNonDecreasingf(object interface{}, msg string, args ...interface{}) bool

func IsNonIncreasing

func IsNonIncreasing(object interface{}, msgAndArgs ...interface{}) bool

func IsNonIncreasingf

func IsNonIncreasingf(object interface{}, msg string, args ...interface{}) bool

func IsType

func IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool

func IsTypef

func IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool

func JSONEq

func JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool

func JSONEqf

func JSONEqf(expected string, actual string, msg string, args ...interface{}) bool

func Len

func Len(object interface{}, length int, msgAndArgs ...interface{}) bool

func Lenf

func Lenf(object interface{}, length int, msg string, args ...interface{}) bool

func Less

func Less(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool

func LessOrEqual

func LessOrEqual(e1 interface{}, e2 interface{}, msgAndArgs ...interface{}) bool

func LessOrEqualf

func LessOrEqualf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool

func Lessf

func Lessf(e1 interface{}, e2 interface{}, msg string, args ...interface{}) bool

func Negative

func Negative(e interface{}, msgAndArgs ...interface{}) bool

func Negativef

func Negativef(e interface{}, msg string, args ...interface{}) bool

func Never

func Never(condition func() bool, waitFor time.Duration, tick time.Duration, msgAndArgs ...interface{}) bool

func Neverf

func Neverf(condition func() bool, waitFor time.Duration, tick time.Duration, msg string, args ...interface{}) bool

func Nil

func Nil(object interface{}, msgAndArgs ...interface{}) bool

func Nilf

func Nilf(object interface{}, msg string, args ...interface{}) bool

func NoDirExists

func NoDirExists(path string, msgAndArgs ...interface{}) bool

func NoDirExistsf

func NoDirExistsf(path string, msg string, args ...interface{}) bool

func NoError

func NoError(err error, msgAndArgs ...interface{}) bool

func NoErrorf

func NoErrorf(err error, msg string, args ...interface{}) bool

func NoFileExists

func NoFileExists(path string, msgAndArgs ...interface{}) bool

func NoFileExistsf

func NoFileExistsf(path string, msg string, args ...interface{}) bool

func NotContains

func NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool

func NotContainsf

func NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool

func NotEmpty

func NotEmpty(object interface{}, msgAndArgs ...interface{}) bool

func NotEmptyf

func NotEmptyf(object interface{}, msg string, args ...interface{}) bool

func NotEqual

func NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool

func NotEqualValues

func NotEqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool

func NotEqualValuesf

func NotEqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func NotEqualf

func NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func NotErrorIs

func NotErrorIs(err error, target error, msgAndArgs ...interface{}) bool

func NotErrorIsf

func NotErrorIsf(err error, target error, msg string, args ...interface{}) bool

func NotNil

func NotNil(object interface{}, msgAndArgs ...interface{}) bool

func NotNilf

func NotNilf(object interface{}, msg string, args ...interface{}) bool

func NotPanics

func NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool

func NotPanicsf

func NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) bool

func NotRegexp

func NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool

func NotRegexpf

func NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool

func NotSame

func NotSame(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool

func NotSamef

func NotSamef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func NotSubset

func NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool

func NotSubsetf

func NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool

func NotZero

func NotZero(i interface{}, msgAndArgs ...interface{}) bool

func NotZerof

func NotZerof(i interface{}, msg string, args ...interface{}) bool

func Panics

func Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) bool

func PanicsWithError

func PanicsWithError(errString string, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool

func PanicsWithErrorf

func PanicsWithErrorf(errString string, f assert.PanicTestFunc, msg string, args ...interface{}) bool

func PanicsWithValue

func PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool

func PanicsWithValuef

func PanicsWithValuef(expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) bool

func Panicsf

func Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) bool

func Positive

func Positive(e interface{}, msgAndArgs ...interface{}) bool

func Positivef

func Positivef(e interface{}, msg string, args ...interface{}) bool

func Regexp

func Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool

func Regexpf

func Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool

func Same

func Same(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool

func Samef

func Samef(expected interface{}, actual interface{}, msg string, args ...interface{}) bool

func Subset

func Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool

func Subsetf

func Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool

func True

func True(value bool, msgAndArgs ...interface{}) bool

func Truef

func Truef(value bool, msg string, args ...interface{}) bool

func WithinDuration

func WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool

func WithinDurationf

func WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool

func WithinRange

func WithinRange(actual time.Time, start time.Time, end time.Time, msgAndArgs ...interface{}) bool

func WithinRangef

func WithinRangef(actual time.Time, start time.Time, end time.Time, msg string, args ...interface{}) bool

func YAMLEq

func YAMLEq(expected string, actual string, msgAndArgs ...interface{}) bool

func YAMLEqf

func YAMLEqf(expected string, actual string, msg string, args ...interface{}) bool

func Zero

func Zero(i interface{}, msgAndArgs ...interface{}) bool

func Zerof

func Zerof(i interface{}, msg string, args ...interface{}) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL