Documentation ¶
Overview ¶
Package jtest provides simple test assertion functions for the jettison errors package.
The style is similar to the assert and require packages of the github.com/stretchr/testify library.
Index ¶
- func Assert(t testing.TB, expected, actual error, msgs ...interface{}) bool
- func AssertKeyValues(t testing.TB, expKVs j.MKS, err error, msg ...any) bool
- func AssertNil(t testing.TB, actual error, msgs ...interface{}) bool
- func Require(t testing.TB, expected, actual error, msg ...interface{})
- func RequireKeyValues(t testing.TB, kvs j.MKS, err error, msg ...any) bool
- func RequireNil(t testing.TB, actual error, msg ...interface{})
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Assert asserts that the specified error matches the expected one. The test will be marked failed if it does not.
jtest.Assert(t, ErrWhatIExpect, err)
func AssertKeyValues ¶
AssertKeyValues asserts that err contains at least the key values in kvs
jtest.AssertKeyValues(t, j.MKS{"key":"value"}, err)
If err contains keys that aren't in kvs they are ignored If err doesn't contain a key in kvs, then the test will fail
func AssertNil ¶
AssertNil asserts that the specified error is nil. The test will be marked failed if it does not. It is shorthand for `jtest.Assert(t, nil, err)`, although it provides slightly clearer failure output.
jtest.AssertNil(t, err)
func Require ¶
Require asserts that the specified error matches the expected one. The test will be marked failed if it does not. It also stops test execution when it fails.
jtest.Require(t, ErrWhatIExpect, err)
func RequireKeyValues ¶
RequireKeyValues asserts that err contains at least the key values in kvs
jtest.RequireKeyValues(t, j.MKS{"key":"value"}, err)
If the assertion fails then the test will terminate immediately. See AssertKeyValues for more details
func RequireNil ¶
RequireNil asserts that the specified error is nil. The test will be marked failed if it does not, and execution will be stopped. It is shorthand for `jtest.Require(t, nil, err)`, although it provides slightly clearer failure output.
jtest.RequireNil(t, err)
Types ¶
This section is empty.