Documentation ¶
Overview ¶
Package test contains helpers for aiding testing.
Index ¶
- Variables
- func BindJSON(r io.Reader, target interface{}) error
- func DialGRPC(addr string, opts ...grpc.DialOption) *grpc.ClientConn
- func Equals(tb testing.TB, expected, actual interface{})
- func NotEquals(tb testing.TB, expected, actual interface{})
- func ToJSONBody(tb testing.TB, i interface{}) io.Reader
- type ErrorReporter
Constants ¶
This section is empty.
Variables ¶
var ErrorTypeComparer = cmp.Comparer(func(x error, y error) bool { return reflect.TypeOf(x) == reflect.TypeOf(y) })
ErrorTypeComparer defines an error type comparator for use with go-cmp Example:
opts := cmp.Options{ test.ErrorTypeComparer, } if !cmp.Equal(err, MyCustomError{}, opts) { t.Fatal(e.String()) }
Functions ¶
func DialGRPC ¶
func DialGRPC(addr string, opts ...grpc.DialOption) *grpc.ClientConn
DialGRPC will connect to a grpc server on a specific port.
func Equals ¶
Equals performs a deep equal comparison against two values and fails if they are not the same.
Types ¶
type ErrorReporter ¶
type ErrorReporter struct {
// contains filtered or unexported fields
}
ErrorReporter defines a reporter for use with go-cmp. This enables producing elegant diff output when the ErrorTypeComparator reports unequal.
func (*ErrorReporter) PopStep ¶
func (e *ErrorReporter) PopStep()
PopStep is always called after Report. This method is defined in the reporterIface interface for go-cmp.
func (*ErrorReporter) PushStep ¶
func (e *ErrorReporter) PushStep(ps cmp.PathStep)
PushStep is always called before report. This method is defined in the reporterIface interface for go-cmp.
func (*ErrorReporter) Report ¶
func (e *ErrorReporter) Report(rs cmp.Result)
Report is always called after PushStep and before PopStep. It is called wether the comparison reports equal, unequal or is ignored. This method is defined in the reporterIface interface for go-cmp.
func (ErrorReporter) String ¶
func (e ErrorReporter) String() string
String implements the Stringer interface.