Documentation ¶
Overview ¶
Package assertions is designed to be a collection of `.` importable, goconvey compatible testing assertions, in the style of "github.com/smarty/assertions".
Due to a bug/feature in goconvey1, files in this package end in `_tests.go`.
This is a signal to goconvey's internal stack traversal logic (used to print helpful assertion messages) that the assertions in this package should be considered 'testing code' and not 'tested code', and so should be skipped over when searching for the first stack frame containing the code under test.
Index ¶
- func ShouldBeRPCAborted(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCAlreadyExists(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCFailedPrecondition(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCInternal(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCInvalidArgument(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCNotFound(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCOK(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCPermissionDenied(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCUnauthenticated(actual interface{}, expected ...interface{}) string
- func ShouldBeRPCUnknown(actual interface{}, expected ...interface{}) string
- func ShouldErrLike(actual interface{}, expected ...interface{}) string
- func ShouldHaveRPCCode(actual interface{}, expected ...interface{}) string
- func ShouldPanicLike(function interface{}, expected ...interface{}) (ret string)
- func ShouldResembleProto(actual interface{}, expected ...interface{}) string
- func ShouldUnwrapTo(actual interface{}, expected ...interface{}) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ShouldBeRPCAborted ¶
func ShouldBeRPCAborted(actual interface{}, expected ...interface{}) string
ShouldBeRPCAborted asserts that "actual" is an error that has a gRPC code value of codes.Aborted.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCAlreadyExists ¶
func ShouldBeRPCAlreadyExists(actual interface{}, expected ...interface{}) string
ShouldBeRPCAlreadyExists asserts that "actual" is an error that has a gRPC code value of codes.AlreadyExists.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCFailedPrecondition ¶
func ShouldBeRPCFailedPrecondition(actual interface{}, expected ...interface{}) string
ShouldBeRPCFailedPrecondition asserts that "actual" is an error that has a gRPC code value of codes.FailedPrecondition.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCInternal ¶
func ShouldBeRPCInternal(actual interface{}, expected ...interface{}) string
ShouldBeRPCInternal asserts that "actual" is an error that has a gRPC code value of codes.Internal.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCInvalidArgument ¶
func ShouldBeRPCInvalidArgument(actual interface{}, expected ...interface{}) string
ShouldBeRPCInvalidArgument asserts that "actual" is an error that has a gRPC code value of codes.InvalidArgument.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCNotFound ¶
func ShouldBeRPCNotFound(actual interface{}, expected ...interface{}) string
ShouldBeRPCNotFound asserts that "actual" is an error that has a gRPC code value of codes.NotFound.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCOK ¶
func ShouldBeRPCOK(actual interface{}, expected ...interface{}) string
ShouldBeRPCOK asserts that "actual" is an error that has a gRPC code value of codes.OK.
Note that "nil" has an codes.OK value.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCPermissionDenied ¶
func ShouldBeRPCPermissionDenied(actual interface{}, expected ...interface{}) string
ShouldBeRPCPermissionDenied asserts that "actual" is an error that has a gRPC code value of codes.PermissionDenied.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCUnauthenticated ¶
func ShouldBeRPCUnauthenticated(actual interface{}, expected ...interface{}) string
ShouldBeRPCUnauthenticated asserts that "actual" is an error that has a gRPC code value of codes.Unauthenticated.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldBeRPCUnknown ¶
func ShouldBeRPCUnknown(actual interface{}, expected ...interface{}) string
ShouldBeRPCUnknown asserts that "actual" is an error that has a gRPC code value of codes.Unknown.
One additional "expected" string may be optionally included. If included, the gRPC error's message is asserted to contain the expected string.
func ShouldErrLike ¶
func ShouldErrLike(actual interface{}, expected ...interface{}) string
ShouldErrLike compares an `error` or `string` on the left side, to an `error` or `string` on the right side.
If the righthand side is omitted, this expects `actual` to be nil.
If a singular righthand side is provided, this expects the stringified `actual` to contain the stringified `expected[0]` to be a substring of it.
Example:
// Usage Equivalent To So(err, ShouldErrLike, "custom") // `err.Error()` ShouldContainSubstring "custom" So(err, ShouldErrLike, io.EOF) // `err.Error()` ShouldContainSubstring io.EOF.Error() So(err, ShouldErrLike, "EOF") // `err.Error()` ShouldContainSubstring "EOF" So(nilErr, ShouldErrLike) // nilErr ShouldBeNil So(nilErr, ShouldErrLike, nil) // nilErr ShouldBeNil So(nonNilErr, ShouldErrLike, "foo") // nonNilErr ShouldNotBeNil
func ShouldHaveRPCCode ¶
func ShouldHaveRPCCode(actual interface{}, expected ...interface{}) string
ShouldHaveRPCCode is a goconvey assertion, asserting that the supplied "actual" value has a gRPC code value and, optionally, errors like a supplied message string.
If no "expected" arguments are supplied, ShouldHaveRPCCode will assert that the result is codes.OK.
The first "expected" argument, if supplied, is the gRPC codes.Code to assert.
A second "expected" string may be optionally included. If included, the gRPC error message is asserted to contain the expected string using convey.ShouldContainSubstring.
func ShouldPanicLike ¶
func ShouldPanicLike(function interface{}, expected ...interface{}) (ret string)
ShouldPanicLike is the same as ShouldErrLike, but with the exception that it takes a panic'ing func() as its first argument, instead of the error itself.
func ShouldResembleProto ¶
func ShouldResembleProto(actual interface{}, expected ...interface{}) string
ShouldResembleProto asserts that given two values that contain proto messages are equal by comparing their types and ensuring they serialize to the same text representation.
Values can either each be a proto.Message or a slice of values that each implement proto.Message interface.
func ShouldUnwrapTo ¶
func ShouldUnwrapTo(actual interface{}, expected ...interface{}) string
ShouldUnwrapTo asserts that an error, when unwrapped, equals another error.
The actual field will be unwrapped using errors.Unwrap and then compared to the error in expected.
Types ¶
This section is empty.