Documentation
¶
Overview ¶
Package grpcmock provides functionalities for testing grpc client and server.
Index ¶
- Constants
- func InvokeBidirectionalStream(ctx context.Context, method string, handle ClientStreamHandler, ...) error
- func InvokeClientStream(ctx context.Context, method string, handle ClientStreamHandler, ...) error
- func InvokeServerStream(ctx context.Context, method string, in interface{}, handle ClientStreamHandler, ...) error
- func InvokeUnary(ctx context.Context, method string, in interface{}, out interface{}, ...) error
- func JSONEq(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool
- func MessageEqual(t TestingT, expected, actual proto.Message, msgAndArgs ...interface{}) bool
- type ClientStreamHandler
- type ContextDialer
- type InvokeOption
- func WithBufConnDialer(l *bufconn.Listener) InvokeOption
- func WithCallOption(opts ...grpc.CallOption) InvokeOption
- func WithContextDialer(d ContextDialer) InvokeOption
- func WithDialOptions(opts ...grpc.DialOption) InvokeOption
- func WithHeader(key, value string) InvokeOption
- func WithHeaders(header map[string]string) InvokeOption
- func WithInsecure() InvokeOption
- type TestingT
Constants ¶
const (
// ErrMissingMethod indicates that there is no method in the url.
ErrMissingMethod err = "missing method"
)
Variables ¶
This section is empty.
Functions ¶
func InvokeBidirectionalStream ¶ added in v0.3.0
func InvokeBidirectionalStream( ctx context.Context, method string, handle ClientStreamHandler, opts ...InvokeOption, ) error
InvokeBidirectionalStream invokes a client-server-stream method.
func InvokeClientStream ¶ added in v0.2.0
func InvokeClientStream( ctx context.Context, method string, handle ClientStreamHandler, out interface{}, opts ...InvokeOption, ) error
InvokeClientStream invokes a client-stream method.
func InvokeServerStream ¶ added in v0.2.0
func InvokeServerStream( ctx context.Context, method string, in interface{}, handle ClientStreamHandler, opts ...InvokeOption, ) error
InvokeServerStream invokes a server-stream method.
func InvokeUnary ¶
func InvokeUnary( ctx context.Context, method string, in interface{}, out interface{}, opts ...InvokeOption, ) error
InvokeUnary invokes a unary method.
Types ¶
type ClientStreamHandler ¶ added in v0.2.0
type ClientStreamHandler func(stream grpc.ClientStream) error
ClientStreamHandler handles a client stream.
func RecvAll ¶ added in v0.2.0
func RecvAll(out interface{}) ClientStreamHandler
RecvAll reads everything from the stream and put into the output.
func SendAll ¶ added in v0.2.0
func SendAll(in interface{}) ClientStreamHandler
SendAll sends everything to the stream.
func SendAndRecvAll ¶ added in v0.3.0
func SendAndRecvAll(in interface{}, out interface{}) ClientStreamHandler
SendAndRecvAll sends and receives messages to and from grpc server in turn until server sends the io.EOF.
func (ClientStreamHandler) Handle ¶ added in v0.2.0
func (h ClientStreamHandler) Handle(stream grpc.ClientStream) error
Handle handles a client stream.
type ContextDialer ¶
ContextDialer is to set up the dialer.
type InvokeOption ¶
type InvokeOption func(c *invokeConfig)
InvokeOption sets invoker config.
func WithBufConnDialer ¶
func WithBufConnDialer(l *bufconn.Listener) InvokeOption
WithBufConnDialer sets a *bufconn.Listener as the context dialer.
See:
- grpcmock.WithContextDialer()
func WithCallOption ¶
func WithCallOption(opts ...grpc.CallOption) InvokeOption
WithCallOption sets call options.
func WithContextDialer ¶
func WithContextDialer(d ContextDialer) InvokeOption
WithContextDialer sets a context dialer to create connections.
See:
- grpcmock.WithBufConnDialer()
func WithDialOptions ¶
func WithDialOptions(opts ...grpc.DialOption) InvokeOption
WithDialOptions sets dial options.
func WithHeaders ¶
func WithHeaders(header map[string]string) InvokeOption
WithHeaders sets request header.
func WithInsecure ¶
func WithInsecure() InvokeOption
WithInsecure disables transport security for the connections.
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
mock/grpc
Package grpc provides mock for grpc types.
|
Package grpc provides mock for grpc types. |
|
test
Package test provides functionalities for testing the project.
|
Package test provides functionalities for testing the project. |
|
test/grpctest
Package grpctest provides the test implementation for the grpctest Service.
|
Package grpctest provides the test implementation for the grpctest Service. |
|
Package reflect provides a simple reflection on the grpc server.
|
Package reflect provides a simple reflection on the grpc server. |
