Documentation ¶
Overview ¶
Package test contains some simple utils for more readable tests. It is based on https://github.com/benbjohnson/testing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Assert ¶
Assert fails the test if the condition is false. It returns true, if the test did not fail.
func Equals ¶
Equals fails the test if exp is not equal to act. It returns true, if the test did not fail.
Types ¶
type ExpectedErrorResult ¶ added in v0.2.1
type ExpectedErrorResult int
const ( // IsCorrectNil is returned if both the expected and the actual // error are nil. IsCorrectNil ExpectedErrorResult = iota // IsCorrectErr is returned if both the expected and the actual // error are not nil and identical. IsCorrectErr // IsWrongErr is returned if the expected and the actual error // don't match. IsWrongErr )
func ExpectedError ¶ added in v0.2.1
func ExpectedError(tb testing.TB, exp, act error) ExpectedErrorResult
ExpectError checks if the actual error is expected given error, using errors.Is. In all cases the test Fails if expected does not match actual.
The three states are useful if you want to check for errors and do different things based on the result. For example if the actual error is only in some cases not nil and you want to continue execution in that case, but stop on the other cases.