test

package
Version: v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package test provides helpers for testing grpcmock.

Index

Constants

This section is empty.

Variables

View Source
var NoMockBidirectionalStreamer = MockTransformItemsStreamer()

NoMockBidirectionalStreamer creates an empty mocked stream.

View Source
var NoMockClientStreamer = MockCreateItemsStreamer()

NoMockClientStreamer creates an empty mocked stream.

View Source
var NoMockServerStreamer = MockListItemsStreamer()

NoMockServerStreamer creates an empty mocked stream.

Functions

func CreateItemsSvc

func CreateItemsSvc() service.Method

CreateItemsSvc returns the CreateItems service method.

func DefaultItem

func DefaultItem() *grpctest.Item

DefaultItem provides an item for testing.

func DefaultItems

func DefaultItems() []*grpctest.Item

DefaultItems provides a set of default items.

func GetItemsSvc

func GetItemsSvc() service.Method

GetItemsSvc returns the GetItem service method.

func ListItemsSvc

func ListItemsSvc() service.Method

ListItemsSvc returns the ListItems service method.

func MockCreateItemsStreamer

func MockCreateItemsStreamer(mocks ...func(s *grpcMock.ServerStream)) func(t *testing.T) *streamer.ClientStreamer

MockCreateItemsStreamer creates a mocked stream for creating items.

func MockListItemsStreamer

func MockListItemsStreamer(mocks ...func(s *grpcMock.ServerStream)) func(t *testing.T) *streamer.ServerStreamer

MockListItemsStreamer creates a mocked stream for creating items.

func MockStreamRecvItemEOF

func MockStreamRecvItemEOF() func(s *grpcMock.ServerStream)

MockStreamRecvItemEOF mocks the stream to return io.EOF.

func MockStreamRecvItemSuccess

func MockStreamRecvItemSuccess(i *grpctest.Item) func(s *grpcMock.ServerStream)

MockStreamRecvItemSuccess mocks the stream to receive the given item.

func MockStreamRecvItemsSuccess

func MockStreamRecvItemsSuccess(items ...*grpctest.Item) func(s *grpcMock.ServerStream)

MockStreamRecvItemsSuccess mocks the stream to receive the given items.

func MockStreamSendCreateItemsResponseSuccess

func MockStreamSendCreateItemsResponseSuccess(numItems int64) func(s *grpcMock.ServerStream)

MockStreamSendCreateItemsResponseSuccess mocks the stream to send grpctest.CreateItemsResponse.

func MockStreamSendItemSuccess

func MockStreamSendItemSuccess(i *grpctest.Item) func(s *grpcMock.ServerStream)

MockStreamSendItemSuccess mocks the stream to send the given item.

func MockStreamSendItemsSuccess

func MockStreamSendItemsSuccess(items ...*grpctest.Item) func(s *grpcMock.ServerStream)

MockStreamSendItemsSuccess mocks the stream to send the given items.

func MockTransformItemsStreamer

func MockTransformItemsStreamer(mocks ...func(s *grpcMock.ServerStream)) func(t *testing.T) *streamer.BidirectionalStreamer

MockTransformItemsStreamer creates a mocked stream for creating items.

func NewServer

func NewServer(opts ...ServiceOption) *grpc.Server

NewServer initiates a new grpctest Service.

func StartServer

func StartServer(t *testing.T, opts ...ServiceOption) func(context.Context, string) (net.Conn, error)

StartServer starts a new grpctest Service.

func TransformItemsSvc

func TransformItemsSvc() service.Method

TransformItemsSvc returns the TransformItems service method.

Types

type ItemBuilder

type ItemBuilder struct {
	// contains filtered or unexported fields
}

ItemBuilder builds an item.

func BuildItem

func BuildItem() ItemBuilder

BuildItem builds an item.

func (ItemBuilder) From

func (b ItemBuilder) From(src *grpctest.Item) ItemBuilder

From creates a new item from a source.

func (ItemBuilder) New

func (b ItemBuilder) New() *grpctest.Item

New creates a new item.

func (ItemBuilder) WithID

func (b ItemBuilder) WithID(id int32) ItemBuilder

WithID sets the id.

func (ItemBuilder) WithLocale

func (b ItemBuilder) WithLocale(locale string) ItemBuilder

WithLocale sets the locale.

func (ItemBuilder) WithName

func (b ItemBuilder) WithName(name string) ItemBuilder

WithName sets the name.

type Service

type Service struct {
	grpctest.UnimplementedItemServiceServer
	// contains filtered or unexported fields
}

Service is an implementation of grpctest.ItemServiceServer.

func (*Service) CreateItems

func (s *Service) CreateItems(itemsServer grpctest.ItemService_CreateItemsServer) error

CreateItems satisfies grpctest.ItemServiceServer.

func (*Service) GetItem

func (s *Service) GetItem(ctx context.Context, request *grpctest.GetItemRequest) (*grpctest.Item, error)

GetItem satisfies grpctest.ItemServiceServer.

func (*Service) ListItems

func (s *Service) ListItems(request *grpctest.ListItemsRequest, itemsServer grpctest.ItemService_ListItemsServer) error

ListItems satisfies grpctest.ItemServiceServer.

func (*Service) TransformItems

func (s *Service) TransformItems(itemsServer grpctest.ItemService_TransformItemsServer) error

TransformItems satisfies grpctest.ItemServiceServer.

type ServiceOption

type ServiceOption func(s *Service)

ServiceOption sets up the service.

func CreateItems

func CreateItems(h func(itemsServer grpctest.ItemService_CreateItemsServer) error) ServiceOption

CreateItems sets a handler for creating items.

func GetItem

GetItem sets a handler for getting item.

func ListItems

ListItems sets a handler for listing item.

func TransformItems

func TransformItems(h func(itemsServer grpctest.ItemService_TransformItemsServer) error) ServiceOption

TransformItems sets a handler for transforming items.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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