arpcmocks

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultToken = &oauth2.Token{
	AccessToken:  "secret-access-token",
	TokenType:    "custom-token-type",
	RefreshToken: "refresh-token",
	Expiry:       time.Now().Add(time.Hour),
	ExpiresIn:    999999999,
}
View Source
var ErrAppendCert = errors.New("failed to append certificate to default pool")

Functions

func ClientCerts

func ClientCerts(mocked ...[]byte) func() (*x509.CertPool, error)

func RegisterServiceServerOption

func RegisterServiceServerOption(f func(grpc.ServiceRegistrar)) grpc.ServerOption

RegisterServiceServerOption returns a ServerOption that will run f() in Start or StartServer with the grpc.Server created before serving. This allows other services to be registered on the test server (e.g. ORCA, health, or reflection).

func Server

func Server(srv testgrpc.TestServiceServer, keyFile, certFile []byte) (func(), error)

func TokenSource

func TokenSource(
	token oauth2.TokenSource,
) func(ctx context.Context, audience string, opts ...idtoken.ClientOption) (oauth2.TokenSource, error)

Types

type GRPCServer

type GRPCServer interface {
	grpc.ServiceRegistrar
	Stop()
	GracefulStop()
	Serve(net.Listener) error
}

GRPCServer is an interface that groups methods implemented by a grpc.Server or an xds.GRPCServer that are used by the StubServer.

type IDTokenStub

type IDTokenStub struct {
	oauth2.TokenSource
}

func (*IDTokenStub) Token

func (i *IDTokenStub) Token() (*oauth2.Token, error)

type MockConnPool

type MockConnPool struct {
	mock.Mock
}

MockConnPool is an autogenerated mock type for the ConnPool type

func NewMockConnPool

func NewMockConnPool(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockConnPool

NewMockConnPool creates a new instance of MockConnPool. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockConnPool) Close

func (_m *MockConnPool) Close()

Close provides a mock function with given fields:

func (*MockConnPool) EXPECT

func (_m *MockConnPool) EXPECT() *MockConnPool_Expecter

func (*MockConnPool) Open

func (_m *MockConnPool) Open(ctx context.Context, host string, port int, protocol arpc.Protocol) (*grpc.ClientConn, error)

Open provides a mock function with given fields: ctx, host, port, protocol

type MockConnPool_Close_Call

type MockConnPool_Close_Call struct {
	*mock.Call
}

MockConnPool_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'

func (*MockConnPool_Close_Call) Return

func (*MockConnPool_Close_Call) Run

func (_c *MockConnPool_Close_Call) Run(run func()) *MockConnPool_Close_Call

func (*MockConnPool_Close_Call) RunAndReturn

func (_c *MockConnPool_Close_Call) RunAndReturn(run func()) *MockConnPool_Close_Call

type MockConnPool_Expecter

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

func (*MockConnPool_Expecter) Close

Close is a helper method to define mock.On call

func (*MockConnPool_Expecter) Open

func (_e *MockConnPool_Expecter) Open(ctx interface{}, host interface{}, port interface{}, protocol interface{}) *MockConnPool_Open_Call

Open is a helper method to define mock.On call

  • ctx context.Context
  • host string
  • port int
  • protocol arpc.Protocol

type MockConnPool_Open_Call

type MockConnPool_Open_Call struct {
	*mock.Call
}

MockConnPool_Open_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Open'

func (*MockConnPool_Open_Call) Return

func (*MockConnPool_Open_Call) Run

func (_c *MockConnPool_Open_Call) Run(run func(ctx context.Context, host string, port int, protocol arpc.Protocol)) *MockConnPool_Open_Call

func (*MockConnPool_Open_Call) RunAndReturn

type MockErrorHandler

type MockErrorHandler struct {
	mock.Mock
}

MockErrorHandler is an autogenerated mock type for the ErrorHandler type

func NewMockErrorHandler

func NewMockErrorHandler(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockErrorHandler

NewMockErrorHandler creates a new instance of MockErrorHandler. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockErrorHandler) As

func (_m *MockErrorHandler) As(target interface{}, code codes.Code) arpc.ErrorHandler

As provides a mock function with given fields: target, code

func (*MockErrorHandler) AsW

func (_m *MockErrorHandler) AsW(target interface{}, code codes.Code, wrap error) arpc.ErrorHandler

AsW provides a mock function with given fields: target, code, wrap

func (*MockErrorHandler) AsWF

func (_m *MockErrorHandler) AsWF(target interface{}, code codes.Code, format string, args ...interface{}) arpc.ErrorHandler

AsWF provides a mock function with given fields: target, code, format, args

func (*MockErrorHandler) EXPECT

func (*MockErrorHandler) Handle

func (_m *MockErrorHandler) Handle(err error) error

Handle provides a mock function with given fields: err

func (*MockErrorHandler) Is

func (_m *MockErrorHandler) Is(target error, code codes.Code) arpc.ErrorHandler

Is provides a mock function with given fields: target, code

func (*MockErrorHandler) IsW

func (_m *MockErrorHandler) IsW(target error, code codes.Code, wrap error) arpc.ErrorHandler

IsW provides a mock function with given fields: target, code, wrap

func (*MockErrorHandler) IsWF

func (_m *MockErrorHandler) IsWF(target error, code codes.Code, format string, args ...interface{}) arpc.ErrorHandler

IsWF provides a mock function with given fields: target, code, format, args

func (*MockErrorHandler) Test

func (_m *MockErrorHandler) Test(caseFn func(error) (error, bool)) arpc.ErrorHandler

Test provides a mock function with given fields: caseFn

type MockErrorHandler_AsWF_Call

type MockErrorHandler_AsWF_Call struct {
	*mock.Call
}

MockErrorHandler_AsWF_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AsWF'

func (*MockErrorHandler_AsWF_Call) Return

func (*MockErrorHandler_AsWF_Call) Run

func (_c *MockErrorHandler_AsWF_Call) Run(run func(target interface{}, code codes.Code, format string, args ...interface{})) *MockErrorHandler_AsWF_Call

func (*MockErrorHandler_AsWF_Call) RunAndReturn

func (_c *MockErrorHandler_AsWF_Call) RunAndReturn(run func(interface{}, codes.Code, string, ...interface{}) arpc.ErrorHandler) *MockErrorHandler_AsWF_Call

type MockErrorHandler_AsW_Call

type MockErrorHandler_AsW_Call struct {
	*mock.Call
}

MockErrorHandler_AsW_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'AsW'

func (*MockErrorHandler_AsW_Call) Return

func (*MockErrorHandler_AsW_Call) Run

func (_c *MockErrorHandler_AsW_Call) Run(run func(target interface{}, code codes.Code, wrap error)) *MockErrorHandler_AsW_Call

func (*MockErrorHandler_AsW_Call) RunAndReturn

func (_c *MockErrorHandler_AsW_Call) RunAndReturn(run func(interface{}, codes.Code, error) arpc.ErrorHandler) *MockErrorHandler_AsW_Call

type MockErrorHandler_As_Call

type MockErrorHandler_As_Call struct {
	*mock.Call
}

MockErrorHandler_As_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'As'

func (*MockErrorHandler_As_Call) Return

func (*MockErrorHandler_As_Call) Run

func (_c *MockErrorHandler_As_Call) Run(run func(target interface{}, code codes.Code)) *MockErrorHandler_As_Call

func (*MockErrorHandler_As_Call) RunAndReturn

func (_c *MockErrorHandler_As_Call) RunAndReturn(run func(interface{}, codes.Code) arpc.ErrorHandler) *MockErrorHandler_As_Call

type MockErrorHandler_Expecter

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

func (*MockErrorHandler_Expecter) As

func (_e *MockErrorHandler_Expecter) As(target interface{}, code interface{}) *MockErrorHandler_As_Call

As is a helper method to define mock.On call

  • target interface{}
  • code codes.Code

func (*MockErrorHandler_Expecter) AsW

func (_e *MockErrorHandler_Expecter) AsW(target interface{}, code interface{}, wrap interface{}) *MockErrorHandler_AsW_Call

AsW is a helper method to define mock.On call

  • target interface{}
  • code codes.Code
  • wrap error

func (*MockErrorHandler_Expecter) AsWF

func (_e *MockErrorHandler_Expecter) AsWF(target interface{}, code interface{}, format interface{}, args ...interface{}) *MockErrorHandler_AsWF_Call

AsWF is a helper method to define mock.On call

  • target interface{}
  • code codes.Code
  • format string
  • args ...interface{}

func (*MockErrorHandler_Expecter) Handle

func (_e *MockErrorHandler_Expecter) Handle(err interface{}) *MockErrorHandler_Handle_Call

Handle is a helper method to define mock.On call

  • err error

func (*MockErrorHandler_Expecter) Is

func (_e *MockErrorHandler_Expecter) Is(target interface{}, code interface{}) *MockErrorHandler_Is_Call

Is is a helper method to define mock.On call

  • target error
  • code codes.Code

func (*MockErrorHandler_Expecter) IsW

func (_e *MockErrorHandler_Expecter) IsW(target interface{}, code interface{}, wrap interface{}) *MockErrorHandler_IsW_Call

IsW is a helper method to define mock.On call

  • target error
  • code codes.Code
  • wrap error

func (*MockErrorHandler_Expecter) IsWF

func (_e *MockErrorHandler_Expecter) IsWF(target interface{}, code interface{}, format interface{}, args ...interface{}) *MockErrorHandler_IsWF_Call

IsWF is a helper method to define mock.On call

  • target error
  • code codes.Code
  • format string
  • args ...interface{}

func (*MockErrorHandler_Expecter) Test

func (_e *MockErrorHandler_Expecter) Test(caseFn interface{}) *MockErrorHandler_Test_Call

Test is a helper method to define mock.On call

  • caseFn func(error)(error , bool)

type MockErrorHandler_Handle_Call

type MockErrorHandler_Handle_Call struct {
	*mock.Call
}

MockErrorHandler_Handle_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Handle'

func (*MockErrorHandler_Handle_Call) Return

func (*MockErrorHandler_Handle_Call) Run

func (*MockErrorHandler_Handle_Call) RunAndReturn

type MockErrorHandler_IsWF_Call

type MockErrorHandler_IsWF_Call struct {
	*mock.Call
}

MockErrorHandler_IsWF_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsWF'

func (*MockErrorHandler_IsWF_Call) Return

func (*MockErrorHandler_IsWF_Call) Run

func (_c *MockErrorHandler_IsWF_Call) Run(run func(target error, code codes.Code, format string, args ...interface{})) *MockErrorHandler_IsWF_Call

func (*MockErrorHandler_IsWF_Call) RunAndReturn

func (_c *MockErrorHandler_IsWF_Call) RunAndReturn(run func(error, codes.Code, string, ...interface{}) arpc.ErrorHandler) *MockErrorHandler_IsWF_Call

type MockErrorHandler_IsW_Call

type MockErrorHandler_IsW_Call struct {
	*mock.Call
}

MockErrorHandler_IsW_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsW'

func (*MockErrorHandler_IsW_Call) Return

func (*MockErrorHandler_IsW_Call) Run

func (_c *MockErrorHandler_IsW_Call) Run(run func(target error, code codes.Code, wrap error)) *MockErrorHandler_IsW_Call

func (*MockErrorHandler_IsW_Call) RunAndReturn

type MockErrorHandler_Is_Call

type MockErrorHandler_Is_Call struct {
	*mock.Call
}

MockErrorHandler_Is_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Is'

func (*MockErrorHandler_Is_Call) Return

func (*MockErrorHandler_Is_Call) Run

func (_c *MockErrorHandler_Is_Call) Run(run func(target error, code codes.Code)) *MockErrorHandler_Is_Call

func (*MockErrorHandler_Is_Call) RunAndReturn

type MockErrorHandler_Test_Call

type MockErrorHandler_Test_Call struct {
	*mock.Call
}

MockErrorHandler_Test_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Test'

func (*MockErrorHandler_Test_Call) Return

func (*MockErrorHandler_Test_Call) Run

func (_c *MockErrorHandler_Test_Call) Run(run func(caseFn func(error) (error, bool))) *MockErrorHandler_Test_Call

func (*MockErrorHandler_Test_Call) RunAndReturn

type MockExecService

type MockExecService[In interface{}, Out interface{}] struct {
	mock.Mock
}

MockExecService is an autogenerated mock type for the ExecService type

func NewMockExecService

func NewMockExecService[In interface{}, Out interface{}](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockExecService[In, Out]

NewMockExecService creates a new instance of MockExecService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockExecService[In, Out]) EXPECT

func (_m *MockExecService[In, Out]) EXPECT() *MockExecService_Expecter[In, Out]

func (*MockExecService[In, Out]) Exec

func (_m *MockExecService[In, Out]) Exec(ctx context.Context, data In) (Out, error)

Exec provides a mock function with given fields: ctx, data

type MockExecService_Exec_Call

type MockExecService_Exec_Call[In interface{}, Out interface{}] struct {
	*mock.Call
}

MockExecService_Exec_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Exec'

func (*MockExecService_Exec_Call[In, Out]) Return

func (_c *MockExecService_Exec_Call[In, Out]) Return(_a0 Out, _a1 error) *MockExecService_Exec_Call[In, Out]

func (*MockExecService_Exec_Call[In, Out]) Run

func (_c *MockExecService_Exec_Call[In, Out]) Run(run func(ctx context.Context, data In)) *MockExecService_Exec_Call[In, Out]

func (*MockExecService_Exec_Call[In, Out]) RunAndReturn

func (_c *MockExecService_Exec_Call[In, Out]) RunAndReturn(run func(context.Context, In) (Out, error)) *MockExecService_Exec_Call[In, Out]

type MockExecService_Expecter

type MockExecService_Expecter[In interface{}, Out interface{}] struct {
	// contains filtered or unexported fields
}

func (*MockExecService_Expecter[In, Out]) Exec

func (_e *MockExecService_Expecter[In, Out]) Exec(ctx interface{}, data interface{}) *MockExecService_Exec_Call[In, Out]

Exec is a helper method to define mock.On call

  • ctx context.Context
  • data In

type MockGRPCCallback

type MockGRPCCallback[In interface{}, Out interface{}] struct {
	mock.Mock
}

MockGRPCCallback is an autogenerated mock type for the GRPCCallback type

func NewMockGRPCCallback

func NewMockGRPCCallback[In interface{}, Out interface{}](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockGRPCCallback[In, Out]

NewMockGRPCCallback creates a new instance of MockGRPCCallback. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockGRPCCallback[In, Out]) EXPECT

func (_m *MockGRPCCallback[In, Out]) EXPECT() *MockGRPCCallback_Expecter[In, Out]

func (*MockGRPCCallback[In, Out]) Execute

func (_m *MockGRPCCallback[In, Out]) Execute(ctx context.Context, in In) (Out, error)

Execute provides a mock function with given fields: ctx, in

type MockGRPCCallback_Execute_Call

type MockGRPCCallback_Execute_Call[In interface{}, Out interface{}] struct {
	*mock.Call
}

MockGRPCCallback_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute'

func (*MockGRPCCallback_Execute_Call[In, Out]) Return

func (_c *MockGRPCCallback_Execute_Call[In, Out]) Return(_a0 Out, _a1 error) *MockGRPCCallback_Execute_Call[In, Out]

func (*MockGRPCCallback_Execute_Call[In, Out]) Run

func (_c *MockGRPCCallback_Execute_Call[In, Out]) Run(run func(ctx context.Context, in In)) *MockGRPCCallback_Execute_Call[In, Out]

func (*MockGRPCCallback_Execute_Call[In, Out]) RunAndReturn

func (_c *MockGRPCCallback_Execute_Call[In, Out]) RunAndReturn(run func(context.Context, In) (Out, error)) *MockGRPCCallback_Execute_Call[In, Out]

type MockGRPCCallback_Expecter

type MockGRPCCallback_Expecter[In interface{}, Out interface{}] struct {
	// contains filtered or unexported fields
}

func (*MockGRPCCallback_Expecter[In, Out]) Execute

func (_e *MockGRPCCallback_Expecter[In, Out]) Execute(ctx interface{}, in interface{}) *MockGRPCCallback_Execute_Call[In, Out]

Execute is a helper method to define mock.On call

  • ctx context.Context
  • in In

type MockGRPCServer

type MockGRPCServer struct {
	mock.Mock
}

MockGRPCServer is an autogenerated mock type for the GRPCServer type

func NewMockGRPCServer

func NewMockGRPCServer(t interface {
	mock.TestingT
	Cleanup(func())
}) *MockGRPCServer

NewMockGRPCServer creates a new instance of MockGRPCServer. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockGRPCServer) EXPECT

func (*MockGRPCServer) GracefulStop

func (_m *MockGRPCServer) GracefulStop()

GracefulStop provides a mock function with given fields:

func (*MockGRPCServer) RegisterService

func (_m *MockGRPCServer) RegisterService(desc *grpc.ServiceDesc, impl interface{})

RegisterService provides a mock function with given fields: desc, impl

func (*MockGRPCServer) Serve

func (_m *MockGRPCServer) Serve(_a0 net.Listener) error

Serve provides a mock function with given fields: _a0

func (*MockGRPCServer) Stop

func (_m *MockGRPCServer) Stop()

Stop provides a mock function with given fields:

type MockGRPCServer_Expecter

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

func (*MockGRPCServer_Expecter) GracefulStop

GracefulStop is a helper method to define mock.On call

func (*MockGRPCServer_Expecter) RegisterService

func (_e *MockGRPCServer_Expecter) RegisterService(desc interface{}, impl interface{}) *MockGRPCServer_RegisterService_Call

RegisterService is a helper method to define mock.On call

  • desc *grpc.ServiceDesc
  • impl interface{}

func (*MockGRPCServer_Expecter) Serve

func (_e *MockGRPCServer_Expecter) Serve(_a0 interface{}) *MockGRPCServer_Serve_Call

Serve is a helper method to define mock.On call

  • _a0 net.Listener

func (*MockGRPCServer_Expecter) Stop

Stop is a helper method to define mock.On call

type MockGRPCServer_GracefulStop_Call

type MockGRPCServer_GracefulStop_Call struct {
	*mock.Call
}

MockGRPCServer_GracefulStop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GracefulStop'

func (*MockGRPCServer_GracefulStop_Call) Return

func (*MockGRPCServer_GracefulStop_Call) Run

func (*MockGRPCServer_GracefulStop_Call) RunAndReturn

type MockGRPCServer_RegisterService_Call

type MockGRPCServer_RegisterService_Call struct {
	*mock.Call
}

MockGRPCServer_RegisterService_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RegisterService'

func (*MockGRPCServer_RegisterService_Call) Return

func (*MockGRPCServer_RegisterService_Call) Run

func (*MockGRPCServer_RegisterService_Call) RunAndReturn

type MockGRPCServer_Serve_Call

type MockGRPCServer_Serve_Call struct {
	*mock.Call
}

MockGRPCServer_Serve_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Serve'

func (*MockGRPCServer_Serve_Call) Return

func (*MockGRPCServer_Serve_Call) Run

func (*MockGRPCServer_Serve_Call) RunAndReturn

type MockGRPCServer_Stop_Call

type MockGRPCServer_Stop_Call struct {
	*mock.Call
}

MockGRPCServer_Stop_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Stop'

func (*MockGRPCServer_Stop_Call) Return

func (*MockGRPCServer_Stop_Call) Run

func (*MockGRPCServer_Stop_Call) RunAndReturn

func (_c *MockGRPCServer_Stop_Call) RunAndReturn(run func()) *MockGRPCServer_Stop_Call

type MockProtoConverter

type MockProtoConverter[Proto comparable, Entity comparable] struct {
	mock.Mock
}

MockProtoConverter is an autogenerated mock type for the ProtoConverter type

func NewMockProtoConverter

func NewMockProtoConverter[Proto comparable, Entity comparable](t interface {
	mock.TestingT
	Cleanup(func())
}) *MockProtoConverter[Proto, Entity]

NewMockProtoConverter creates a new instance of MockProtoConverter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. The first argument is typically a *testing.T value.

func (*MockProtoConverter[Proto, Entity]) EXPECT

func (_m *MockProtoConverter[Proto, Entity]) EXPECT() *MockProtoConverter_Expecter[Proto, Entity]

func (*MockProtoConverter[Proto, Entity]) FromProto

func (_m *MockProtoConverter[Proto, Entity]) FromProto(src Proto) Entity

FromProto provides a mock function with given fields: src

func (*MockProtoConverter[Proto, Entity]) ToProto

func (_m *MockProtoConverter[Proto, Entity]) ToProto(src Entity) Proto

ToProto provides a mock function with given fields: src

type MockProtoConverter_Expecter

type MockProtoConverter_Expecter[Proto comparable, Entity comparable] struct {
	// contains filtered or unexported fields
}

func (*MockProtoConverter_Expecter[Proto, Entity]) FromProto

func (_e *MockProtoConverter_Expecter[Proto, Entity]) FromProto(src interface{}) *MockProtoConverter_FromProto_Call[Proto, Entity]

FromProto is a helper method to define mock.On call

  • src Proto

func (*MockProtoConverter_Expecter[Proto, Entity]) ToProto

func (_e *MockProtoConverter_Expecter[Proto, Entity]) ToProto(src interface{}) *MockProtoConverter_ToProto_Call[Proto, Entity]

ToProto is a helper method to define mock.On call

  • src Entity

type MockProtoConverter_FromProto_Call

type MockProtoConverter_FromProto_Call[Proto comparable, Entity comparable] struct {
	*mock.Call
}

MockProtoConverter_FromProto_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'FromProto'

func (*MockProtoConverter_FromProto_Call[Proto, Entity]) Return

func (_c *MockProtoConverter_FromProto_Call[Proto, Entity]) Return(_a0 Entity) *MockProtoConverter_FromProto_Call[Proto, Entity]

func (*MockProtoConverter_FromProto_Call[Proto, Entity]) Run

func (_c *MockProtoConverter_FromProto_Call[Proto, Entity]) Run(run func(src Proto)) *MockProtoConverter_FromProto_Call[Proto, Entity]

func (*MockProtoConverter_FromProto_Call[Proto, Entity]) RunAndReturn

func (_c *MockProtoConverter_FromProto_Call[Proto, Entity]) RunAndReturn(run func(Proto) Entity) *MockProtoConverter_FromProto_Call[Proto, Entity]

type MockProtoConverter_ToProto_Call

type MockProtoConverter_ToProto_Call[Proto comparable, Entity comparable] struct {
	*mock.Call
}

MockProtoConverter_ToProto_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ToProto'

func (*MockProtoConverter_ToProto_Call[Proto, Entity]) Return

func (_c *MockProtoConverter_ToProto_Call[Proto, Entity]) Return(_a0 Proto) *MockProtoConverter_ToProto_Call[Proto, Entity]

func (*MockProtoConverter_ToProto_Call[Proto, Entity]) Run

func (_c *MockProtoConverter_ToProto_Call[Proto, Entity]) Run(run func(src Entity)) *MockProtoConverter_ToProto_Call[Proto, Entity]

func (*MockProtoConverter_ToProto_Call[Proto, Entity]) RunAndReturn

func (_c *MockProtoConverter_ToProto_Call[Proto, Entity]) RunAndReturn(run func(Entity) Proto) *MockProtoConverter_ToProto_Call[Proto, Entity]

type StubServer

type StubServer struct {
	// Guarantees we satisfy this interface; panics if unimplemented methods are called.
	testgrpc.TestServiceServer

	// Customizable implementations of server handlers.
	EmptyCallF      func(ctx context.Context, in *testgrpc.Empty) (*testgrpc.Empty, error)
	UnaryCallF      func(ctx context.Context, in *testgrpc.SimpleRequest) (*testgrpc.SimpleResponse, error)
	FullDuplexCallF func(stream testgrpc.TestService_FullDuplexCallServer) error

	// A client connected to this service the test may use.  Created in Start().
	Client testgrpc.TestServiceClient
	CC     *grpc.ClientConn

	// Server to serve this service from.
	//
	// If nil, a new grpc.Server is created, listening on the provided Network
	// and Address fields, or listening using the provided Listener.
	S GRPCServer

	// Parameters for Listen and Dial. Defaults will be used if these are empty
	// before Start.
	Network string
	Address string
	Target  string

	// Custom listener to use for serving. If unspecified, a new listener is
	// created on a local port.
	Listener net.Listener

	// Set automatically if Target == ""
	R *manual.Resolver
	// contains filtered or unexported fields
}

StubServer is a server that is easy to customize within individual test cases.

func StartTestService

func StartTestService(t *testing.T, server *StubServer, sopts ...grpc.ServerOption) *StubServer

StartTestService spins up a stub server exposing the TestService on a local port. If the passed in server is nil, a stub server that implements only the EmptyCall and UnaryCall RPCs is started.

func (*StubServer) EmptyCall

func (ss *StubServer) EmptyCall(ctx context.Context, in *testgrpc.Empty) (*testgrpc.Empty, error)

EmptyCall is the handler for testgrpc.EmptyCall

func (*StubServer) FullDuplexCall

func (ss *StubServer) FullDuplexCall(stream testgrpc.TestService_FullDuplexCallServer) error

FullDuplexCall is the handler for testgrpc.FullDuplexCall

func (*StubServer) NewServiceConfig

func (ss *StubServer) NewServiceConfig(sc string)

NewServiceConfig applies sc to ss.Client using the resolver (if present).

func (*StubServer) Start

func (ss *StubServer) Start(sopts []grpc.ServerOption, dopts ...grpc.DialOption) error

Start starts the server and creates a client connected to it.

func (*StubServer) StartClient

func (ss *StubServer) StartClient(dopts ...grpc.DialOption) error

StartClient creates a client connected to this service that the test may use. The newly created client will be available in the Client field of StubServer.

func (*StubServer) StartHandlerServer

func (ss *StubServer) StartHandlerServer(sopts ...grpc.ServerOption) error

StartHandlerServer only starts an HTTP server with a gRPC server as the handler. It does not create a client to it. Cannot be used in a StubServer that also used StartServer.

func (*StubServer) StartServer

func (ss *StubServer) StartServer(sopts ...grpc.ServerOption) error

StartServer only starts the server. It does not create a client to it. Cannot be used in a StubServer that also used StartHandlerServer.

func (*StubServer) Stop

func (ss *StubServer) Stop()

Stop stops ss and cleans up all resources it consumed.

func (*StubServer) UnaryCall

UnaryCall is the handler for testgrpc.UnaryCall

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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