Documentation ¶
Index ¶
- func ABCIEventsToStrings(events []abci.Event) []string
- func AssertEqualEvents(t TB, expected, actual sdk.Events, msgAndArgs ...interface{}) bool
- func AssertEqualEventsf(t TB, expected, actual sdk.Events, msg string, args ...interface{}) bool
- func AssertErrorContents(t TB, theError error, contains []string, msgAndArgs ...interface{}) bool
- func AssertErrorContentsf(t TB, theError error, contains []string, msg string, args ...interface{}) bool
- func AssertErrorValue(t TB, theError error, expected string, msgAndArgs ...interface{}) bool
- func AssertErrorValuef(t TB, theError error, expected string, msg string, args ...interface{}) bool
- func AssertEventsContains(t TB, expected, actual sdk.Events, msgAndArgs ...interface{}) bool
- func AssertEventsContainsf(t TB, expected, actual sdk.Events, msg string, args ...interface{}) bool
- func AssertNotPanicsNoError(t TB, f ErrorTestFunc, msgAndArgs ...interface{}) bool
- func AssertNotPanicsNoErrorf(t TB, f ErrorTestFunc, msg string, args ...interface{}) bool
- func AssertPanicContents(t TB, f PanicTestFunc, contains []string, msgAndArgs ...interface{}) bool
- func AssertPanicContentsf(t TB, f PanicTestFunc, contains []string, msg string, args ...interface{}) bool
- func AssertPanicEquals(t TB, f PanicTestFunc, expected string, msgAndArgs ...interface{}) bool
- func AssertPanicEqualsf(t TB, f PanicTestFunc, expected string, msg string, args ...interface{}) bool
- func AttrsToStrings(attrs []abci.EventAttribute) []string
- func EventToString(event sdk.Event) string
- func EventToStrings(event sdk.Event) []string
- func EventsToStrings(events sdk.Events) []string
- func PrependToEach(prefix string, lines []string) []string
- func RequireEqualEvents(t TB, expected, actual sdk.Events, msgAndArgs ...interface{})
- func RequireEqualEventsf(t TB, expected, actual sdk.Events, msg string, args ...interface{})
- func RequireErrorContents(t TB, theError error, contains []string, msgAndArgs ...interface{})
- func RequireErrorContentsf(t TB, theError error, contains []string, msg string, args ...interface{})
- func RequireErrorValue(t TB, theError error, expected string, msgAndArgs ...interface{})
- func RequireErrorValuef(t TB, theError error, expected string, msg string, args ...interface{})
- func RequireEventsContains(t TB, expected, actual sdk.Events, msgAndArgs ...interface{})
- func RequireEventsContainsf(t TB, expected, actual sdk.Events, msg string, args ...interface{})
- func RequireNotPanicsNoError(t TB, f ErrorTestFunc, msgAndArgs ...interface{})
- func RequireNotPanicsNoErrorf(t TB, f ErrorTestFunc, msg string, args ...interface{})
- func RequirePanicContents(t TB, f PanicTestFunc, contains []string, msgAndArgs ...interface{})
- func RequirePanicContentsf(t TB, f PanicTestFunc, contains []string, msg string, args ...interface{})
- func RequirePanicEquals(t TB, f PanicTestFunc, expected string, msgAndArgs ...interface{})
- func RequirePanicEqualsf(t TB, f PanicTestFunc, expected string, msg string, args ...interface{})
- type ErrorTestFunc
- type PanicTestFunc
- type TB
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ABCIEventsToStrings ¶ added in v1.19.0
ABCIEventsToStrings converts abci Events to strings representing the events, one line per attribute.
func AssertEqualEvents ¶
AssertEqualEvents asserts that the expected events equal the actual events.
Returns success (true = they're equal, false = they're different).
func AssertEqualEventsf ¶
AssertEqualEventsf asserts that the expected events equal the actual events.
Returns success (true = they're equal, false = they're different).
func AssertErrorContents ¶
AssertErrorContents asserts that the provided error is as expected. If contains is empty, it asserts there is no error. Otherwise, it asserts that the error contains each of the entries in the contains slice.
Returns true if it's all good, false if one or more assertions failed.
func AssertErrorContentsf ¶
func AssertErrorContentsf(t TB, theError error, contains []string, msg string, args ...interface{}) bool
AssertErrorContentsf asserts that the provided error is as expected. If contains is empty, it asserts there is no error. Otherwise, it asserts that the error contains each of the entries in the contains slice.
Returns true if it's all good, false if one or more assertions failed.
func AssertErrorValue ¶
AssertErrorValue asserts that, if an error is expected, theError equals the expected, otherwise asserts that there wasn't an error.
Returns true if it's all good, false if the assertion failed.
func AssertErrorValuef ¶
AssertErrorValuef asserts that, if an error is expected, theError equals the expected, otherwise asserts that there wasn't an error.
Returns true if it's all good, false if the assertion failed.
func AssertEventsContains ¶ added in v1.18.0
AssertEventsContains asserts that each of the provided expected events is contained in the provided actual events.
Returns success (true = they're all there, false = one or more is missing).
func AssertEventsContainsf ¶ added in v1.18.0
AssertEventsContainsf asserts that each of the provided expected events is contained in the provided actual events.
Returns success (true = they're all there, false = one or more is missing).
func AssertNotPanicsNoError ¶
func AssertNotPanicsNoError(t TB, f ErrorTestFunc, 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, returns false otherwise.
func AssertNotPanicsNoErrorf ¶
func AssertNotPanicsNoErrorf(t TB, f ErrorTestFunc, msg string, args ...interface{}) bool
AssertNotPanicsNoErrorf 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, returns false otherwise.
func AssertPanicContents ¶
func AssertPanicContents(t TB, f PanicTestFunc, contains []string, 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.
Returns true if it's all good, false if an assertion fails.
func AssertPanicContentsf ¶
func AssertPanicContentsf(t TB, f PanicTestFunc, contains []string, msg string, args ...interface{}) bool
AssertPanicContentsf 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.
Returns true if it's all good, false if an assertion fails.
func AssertPanicEquals ¶
func AssertPanicEquals(t TB, f PanicTestFunc, expected string, msgAndArgs ...interface{}) bool
AssertPanicEquals asserts that, if a panic is expected, the provided func panics with the expected output string. And if a panic is not expected, asserts that the provided func does not panic.
Returns true if it's all good, false if an assertion fails.
This can be preferred over PanicsWithError or PanicsWithValue because it doesn't require the panic to be a specific type.
func AssertPanicEqualsf ¶
func AssertPanicEqualsf(t TB, f PanicTestFunc, expected string, msg string, args ...interface{}) bool
AssertPanicEqualsf asserts that, if a panic is expected, the provided func panics with the expected output string. And if a panic is not expected, asserts that the provided func does not panic.
Returns true if it's all good, false if an assertion fails.
This can be preferred over PanicsWithErrorf or PanicsWithValuef because it doesn't require the panic to be a specific type.
func AttrsToStrings ¶
func AttrsToStrings(attrs []abci.EventAttribute) []string
AttrsToStrings creates and returns a string for each attribute.
func EventToString ¶ added in v1.18.0
EventToString converts a single event to a one-line string.
func EventToStrings ¶
EventToStrings converts a single event to strings, one string per attribute.
func EventsToStrings ¶
EventsToStrings converts events to strings representing the events, one line per attribute.
func PrependToEach ¶
PrependToEach prepends the provided prefix to each of the provide lines.
func RequireEqualEvents ¶
RequireEqualEvents asserts that the expected events equal the actual events.
Returns if they're equal, halts tests if not.
func RequireEqualEventsf ¶
RequireEqualEventsf asserts that the expected events equal the actual events.
Returns if they're equal, halts tests if not.
func RequireErrorContents ¶
RequireErrorContents asserts that the provided error is as expected. If contains is empty, it asserts there is no error. Otherwise, it asserts that the error contains each of the entries in the contains slice.
Returns if it's all good, halts the test if one or more assertions failed.
func RequireErrorContentsf ¶
func RequireErrorContentsf(t TB, theError error, contains []string, msg string, args ...interface{})
RequireErrorContentsf asserts that the provided error is as expected. If contains is empty, it asserts there is no error. Otherwise, it asserts that the error contains each of the entries in the contains slice.
Returns if it's all good, halts the test if one or more assertions failed.
func RequireErrorValue ¶
RequireErrorValue asserts that, if an error is expected, theError equals the expected, otherwise asserts that there wasn't an error.
Returns if it's all good, halts the test if the assertion failed.
func RequireErrorValuef ¶
RequireErrorValuef asserts that, if an error is expected, theError equals the expected, otherwise asserts that there wasn't an error.
Returns if it's all good, halts the test if the assertion failed.
func RequireEventsContains ¶ added in v1.18.0
RequireEventsContains asserts that each of the provided expected events is contained in the provided actual events.
Returns if they're all there, halts tests if not.
func RequireEventsContainsf ¶ added in v1.18.0
RequireEventsContainsf asserts that each of the provided expected events is contained in the provided actual events.
Returns if they're all there, halts tests if not.
func RequireNotPanicsNoError ¶
func RequireNotPanicsNoError(t TB, f ErrorTestFunc, msgAndArgs ...interface{})
RequireNotPanicsNoError asserts that the code inside the provided function does not panic and that it does not return an error.
Returns if it neither panics nor errors, otherwise it halts the test.
func RequireNotPanicsNoErrorf ¶
func RequireNotPanicsNoErrorf(t TB, f ErrorTestFunc, msg string, args ...interface{})
RequireNotPanicsNoErrorf asserts that the code inside the provided function does not panic and that it does not return an error.
Returns if it neither panics nor errors, otherwise it halts the test.
func RequirePanicContents ¶
func RequirePanicContents(t TB, f PanicTestFunc, contains []string, 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.
Returns if it's all good, halts the test if the assertion failed.
func RequirePanicContentsf ¶
func RequirePanicContentsf(t TB, f PanicTestFunc, contains []string, msg string, args ...interface{})
RequirePanicContentsf 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.
Returns if it's all good, halts the test if the assertion failed.
func RequirePanicEquals ¶
func RequirePanicEquals(t TB, f PanicTestFunc, expected string, msgAndArgs ...interface{})
RequirePanicEquals asserts that, if a panic is expected, the provided func panics with the expected output string. And if a panic is not expected, asserts that the provided func does not panic.
Returns if it's all good, halts the test if the assertion failed.
This can be preferred over PanicsWithError or PanicsWithValue because it doesn't require the panic to be a specific type.
func RequirePanicEqualsf ¶
func RequirePanicEqualsf(t TB, f PanicTestFunc, expected string, msg string, args ...interface{})
RequirePanicEqualsf asserts that, if a panic is expected, the provided func panics with the expected output string. And if a panic is not expected, asserts that the provided func does not panic.
Returns if it's all good, halts the test if the assertion failed.
This can be preferred over PanicsWithErrorf or PanicsWithValuef because it doesn't require the panic to be a specific type.
Types ¶
type ErrorTestFunc ¶
type ErrorTestFunc func() error
ErrorTestFunc is a type declaration for a function that will be tested for an error.
type PanicTestFunc ¶
type PanicTestFunc func()
PanicTestFunc is a type declaration for a function that will be tested for panic.
type TB ¶
type TB interface { Helper() Errorf(format string, args ...any) Logf(format string, args ...any) FailNow() }
TB is a paired down version of the testing.TB interface with just the stuff needed in here.
I'm kind of annoyed that I needed to do this, but it's the only way I could figure out to have unit tests on these assertions that would check failure conditions, but not fail the parent test.