testutil

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package testutil provides many test helpers/assertions used to simplify common testing patterns.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DiffErr

func DiffErr(op string, resp interface{}, compare interface{}, t *testing.T, opts ...cmp.Option)

DiffErr compares 2 messages (including optional transforms) and throws a testing Fatal on diff. This assumes they are usually proto messages so will automatically include protocmp.Transform() for the caller. It's harmless for the non-proto case. Reduces 3 lines to 1 for common error checking.

func FatalOnErr

func FatalOnErr(op string, e error, t *testing.T)

FatalOnErr is a testing helper function to test and abort on an error. Reduces 3 lines to 1 for common error checking.

func FatalOnNoErr

func FatalOnNoErr(op string, e error, t *testing.T)

FatalOnNoErr is a testing helper function to test and abort when we get no error. Reduces 3 lines to 1 for common error checking.

func ResolvePath

func ResolvePath(t *testing.T, path string) string

ResolvePath takes a binary name and attempts to resolve it for testing or fatal out.

func WantErr

func WantErr(op string, err error, want bool, t *testing.T)

WantErr is a testing helper for comparing boolean expected error state. Reduces 3 lines to 1 for common error checking.

Types

type FakeClientStream

type FakeClientStream struct{}

FakeClientStream provides a null ClientStream for testing.

func (*FakeClientStream) CloseSend

func (*FakeClientStream) CloseSend() error

CloseSend - see grpc.ClientStream

func (*FakeClientStream) Context

func (*FakeClientStream) Context() context.Context

Context - see grpc.ClientStream

func (*FakeClientStream) Header

func (*FakeClientStream) Header() (metadata.MD, error)

Header - see grpc.ClientStream

func (*FakeClientStream) RecvMsg

func (*FakeClientStream) RecvMsg(interface{}) error

RecvMsg - see grpc.ClientStream

func (*FakeClientStream) SendMsg

func (*FakeClientStream) SendMsg(interface{}) error

SendMsg - see grpc.ClientStream

func (*FakeClientStream) Trailer

func (*FakeClientStream) Trailer() metadata.MD

Trailer - see grpc.ClientStream

type FakeServerStream

type FakeServerStream struct {
	Ctx context.Context
}

FakeServerStream provides a null ServerStream for testing

func (*FakeServerStream) Context

func (f *FakeServerStream) Context() context.Context

Context - see grpc.ServerStream

func (*FakeServerStream) RecvMsg

func (*FakeServerStream) RecvMsg(interface{}) error

RecvMsg - see grpc.ServerStream

func (*FakeServerStream) SendHeader

func (*FakeServerStream) SendHeader(metadata.MD) error

SendHeader - see grpc.ServerStream

func (*FakeServerStream) SendMsg

func (*FakeServerStream) SendMsg(interface{}) error

SendMsg - see grpc.ServerStream

func (*FakeServerStream) SetHeader

func (*FakeServerStream) SetHeader(metadata.MD) error

SetHeader - see grpc.ServerStream

func (*FakeServerStream) SetTrailer

func (*FakeServerStream) SetTrailer(metadata.MD)

SetTrailer - see grpc.ServerStream

Jump to

Keyboard shortcuts

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