jtest

package
v0.0.0-...-25be6c5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 7 Imported by: 7

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(t testing.TB, expected, actual error, msgs ...interface{}) bool

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

func AssertKeyValues(t testing.TB, expKVs j.MKS, err error, msg ...any) bool

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

func AssertNil(t testing.TB, actual error, msgs ...interface{}) bool

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

func Require(t testing.TB, expected, actual error, msg ...interface{})

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

func RequireKeyValues(t testing.TB, kvs j.MKS, err error, msg ...any) bool

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

func RequireNil(t testing.TB, actual error, msg ...interface{})

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.

Jump to

Keyboard shortcuts

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