testutil

package
v0.0.0-...-ab54ecc Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertErrorContents

func AssertErrorContents(t *testing.T, theError error, contains []string, msgAndArgs ...interface{}) bool

AssertErrorContents asserts that, if contains is empty, there's no error. Otherwise, asserts that there is an error, and that it contains each of the provided strings.

func AssertNotPanicsNoError

func AssertNotPanicsNoError(t *testing.T, f func() error, msgAndArgs ...interface{}) bool

AssertNotPanicsNoError asserts that the code inside the provided function does not panic and that it does not return an error. Returns true if it neither panics nor errors.

func AssertPanicContents

func AssertPanicContents(t *testing.T, contains []string, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool

AssertPanicContents asserts that, if contains is empty, the provided func does not panic Otherwise, asserts that the func panics and that its panic message contains each of the provided strings.

func AssertPanicsWithMessage

func AssertPanicsWithMessage(t *testing.T, expected string, f assert.PanicTestFunc, msgAndArgs ...interface{}) bool

AssertPanicsWithMessage asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic message equals the expected panic message.

AssertPanicsWithMessage(t, "crazy error", func(){ GoCrazy() })

PanicsWithValue requires a specific interface{} value to be provided, which can be problematic. PanicsWithError requires that the panic value is an error. This one uses fmt.Sprintf("%v", panicValue) to convert the panic recovery value to a string to test against.

func RequireNotPanicsNoError

func RequireNotPanicsNoError(t *testing.T, f func() error, msgAndArgs ...interface{})

RequireNotPanicsNoError asserts that the code inside the provided function does not panic and that it does not return an error.

If the assertion fails, the test is halted.

func RequirePanicContents

func RequirePanicContents(t *testing.T, contains []string, f assert.PanicTestFunc, msgAndArgs ...interface{})

RequirePanicContents asserts that, if contains is empty, the provided func does not panic Otherwise, asserts that the func panics and that its panic message contains each of the provided strings.

If the assertion fails, the test is halted.

func RequirePanicsWithMessage

func RequirePanicsWithMessage(t *testing.T, expected string, f assert.PanicTestFunc, msgAndArgs ...interface{})

RequirePanicsWithMessage asserts that the code inside the specified PanicTestFunc panics, and that the recovered panic message equals the expected panic message.

RequirePanicsWithMessage(t, "crazy error", func(){ GoCrazy() })

PanicsWithValue requires a specific interface{} value to be provided, which can be problematic. PanicsWithError requires that the panic value is an error. This one uses fmt.Sprintf("%v", panicValue) to convert the panic recovery value to a string to test against.

If the assertion fails, the test is halted.

Types

This section is empty.

Jump to

Keyboard shortcuts

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