grpctest

package module
v0.0.0-...-fc4206c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package grpctest provides test utilities for projects that work with gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockServer

type MockServer struct {
	testpb.UnimplementedTestServiceServer
	// contains filtered or unexported fields
}

MockServer is a mock gRPC server that exposes the "grpc.testing" service.

func NewMockServer

func NewMockServer(serverOptions []grpc.ServerOption, dialOptions []grpc.DialOption) *MockServer

NewMockServer returns a new MockServer.

func (*MockServer) ConnectTestClient

func (ms *MockServer) ConnectTestClient(ctx context.Context) (*grpc.ClientConn, testpb.TestServiceClient, error)

ConnectTestClient connects to the mock server and returns a test client. The caller is responsible for closing the ClientConn when done.

func (*MockServer) EmptyCall

func (ms *MockServer) EmptyCall(ctx context.Context, req *testpb.Empty) (*testpb.Empty, error)

EmptyCall calls the handler set with SetEmptyCallHandler. If that handler is nil, it delegates the call to the UnimplementedTestServiceServer.

func (*MockServer) FullDuplexCall

func (ms *MockServer) FullDuplexCall(stream testpb.TestService_FullDuplexCallServer) error

FullDuplexCall calls the handler set with SetFullDuplexCallHandler. If that handler is nil, it delegates the call to the UnimplementedTestServiceServer.

func (*MockServer) HalfDuplexCall

func (ms *MockServer) HalfDuplexCall(stream testpb.TestService_HalfDuplexCallServer) error

HalfDuplexCall calls the handler set with SetHalfDuplexCallHandler. If that handler is nil, it delegates the call to the UnimplementedTestServiceServer.

func (*MockServer) SetEmptyCallHandler

func (ms *MockServer) SetEmptyCallHandler(handler func(context.Context, *testpb.Empty) (*testpb.Empty, error))

SetEmptyCallHandler sets the handler for the EmptyCall RPC.

func (*MockServer) SetFullDuplexCallHandler

func (ms *MockServer) SetFullDuplexCallHandler(handler func(testpb.TestService_FullDuplexCallServer) error)

SetFullDuplexCallHandler sets the handler for the FullDuplexCall RPC.

func (*MockServer) SetHalfDuplexCallHandler

func (ms *MockServer) SetHalfDuplexCallHandler(handler func(testpb.TestService_HalfDuplexCallServer) error)

SetHalfDuplexCallHandler sets the handler for the HalfDuplexCall RPC.

func (*MockServer) SetStreamingInputCallHandler

func (ms *MockServer) SetStreamingInputCallHandler(handler func(testpb.TestService_StreamingInputCallServer) error)

SetStreamingInputCallHandler sets the handler for the StreamingInputCall RPC.

func (*MockServer) SetStreamingOutputCallHandler

func (ms *MockServer) SetStreamingOutputCallHandler(handler func(*testpb.StreamingOutputCallRequest, testpb.TestService_StreamingOutputCallServer) error)

SetStreamingOutputCallHandler sets the handler for the StreamingOutputCall RPC.

func (*MockServer) SetUnaryCallHandler

func (ms *MockServer) SetUnaryCallHandler(handler func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error))

SetUnaryCallHandler sets the handler for the UnaryCall RPC.

func (*MockServer) Start

func (ms *MockServer) Start(ctx context.Context) error

Start starts the mock server. The caller is responsible for stopping the server when done.

func (*MockServer) Stop

func (ms *MockServer) Stop()

Stop stops the mock server.

func (*MockServer) StreamingInputCall

func (ms *MockServer) StreamingInputCall(stream testpb.TestService_StreamingInputCallServer) error

StreamingInputCall calls the handler set with SetStreamingInputCallHandler. If that handler is nil, it delegates the call to the UnimplementedTestServiceServer.

func (*MockServer) StreamingOutputCall

StreamingOutputCall calls the handler set with SetStreamingOutputCallHandler. If that handler is nil, it delegates the call to the UnimplementedTestServiceServer.

func (*MockServer) UnaryCall

UnaryCall calls the handler set with SetUnaryCallHandler. If that handler is nil, it delegates the call to the UnimplementedTestServiceServer.

Jump to

Keyboard shortcuts

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