transporttest

package
v1.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTLDelta = 100 * time.Millisecond

DefaultTTLDelta is the default TTLDelta used by RequestMatchers.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextMatcher

type ContextMatcher struct {
	TTLDelta time.Duration
	// contains filtered or unexported fields
}

ContextMatcher is a Matcher for verifying that a context's deadline is within expected bounds: the current time, plus a TTL, plus or minus some tolerance.

func NewContextMatcher

func NewContextMatcher(t *testing.T, options ...ContextMatcherOption) *ContextMatcher

NewContextMatcher creates a ContextMatcher to verify properties about a Context.

func (*ContextMatcher) Matches

func (c *ContextMatcher) Matches(got interface{}) bool

Matches a context against an expected context, returning true only if the given object is a context with a deadline that is now, plus the expected TTL, plus or minus some tolerance.

func (*ContextMatcher) String

func (c *ContextMatcher) String() string

type ContextMatcherOption

type ContextMatcherOption interface {
	// contains filtered or unexported methods
}

ContextMatcherOption customizes the behavior of a ContextMatcher.

type ContextTTL

type ContextTTL time.Duration

ContextTTL requires that a Context have the given TTL on it, with a tolerance of TTLDelta.

type EchoHandler added in v1.5.0

type EchoHandler struct{}

EchoHandler is a unary handler that echoes the request body on the response body for any inbound request.

func (EchoHandler) Handle added in v1.5.0

Handle handles an inbound request by copying the request body to the response body.

type EchoRouter added in v1.5.0

type EchoRouter struct{}

EchoRouter is a router that echoes all unary inbound requests, with no explicit procedures.

func (EchoRouter) Choose added in v1.5.0

Choose always returns a unary echo handler.

func (EchoRouter) Procedures added in v1.5.0

func (EchoRouter) Procedures() []transport.Procedure

Procedures returns no explicitly supported procedures.

type FakeResponseWriter

type FakeResponseWriter struct {
	IsApplicationError bool
	Headers            transport.Headers
	Body               bytes.Buffer
}

FakeResponseWriter is a ResponseWriter that records the headers and the body written to it.

func (*FakeResponseWriter) AddHeaders

func (fw *FakeResponseWriter) AddHeaders(h transport.Headers)

AddHeaders for FakeResponseWriter.

func (*FakeResponseWriter) SetApplicationError

func (fw *FakeResponseWriter) SetApplicationError()

SetApplicationError for FakeResponseWriter.

func (*FakeResponseWriter) Write

func (fw *FakeResponseWriter) Write(s []byte) (int, error)

Write for FakeResponseWriter.

type MockClientConfig

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

MockClientConfig is a mock of ClientConfig interface

func NewMockClientConfig

func NewMockClientConfig(ctrl *gomock.Controller) *MockClientConfig

NewMockClientConfig creates a new mock instance

func (*MockClientConfig) Caller

func (_m *MockClientConfig) Caller() string

Caller mocks base method

func (*MockClientConfig) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockClientConfig) GetOnewayOutbound

func (_m *MockClientConfig) GetOnewayOutbound() transport.OnewayOutbound

GetOnewayOutbound mocks base method

func (*MockClientConfig) GetUnaryOutbound

func (_m *MockClientConfig) GetUnaryOutbound() transport.UnaryOutbound

GetUnaryOutbound mocks base method

func (*MockClientConfig) Service

func (_m *MockClientConfig) Service() string

Service mocks base method

type MockClientConfigMockRecorder added in v1.10.0

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

MockClientConfigMockRecorder is the mock recorder for MockClientConfig

func (*MockClientConfigMockRecorder) Caller added in v1.10.0

func (_mr *MockClientConfigMockRecorder) Caller() *gomock.Call

Caller indicates an expected call of Caller

func (*MockClientConfigMockRecorder) GetOnewayOutbound added in v1.10.0

func (_mr *MockClientConfigMockRecorder) GetOnewayOutbound() *gomock.Call

GetOnewayOutbound indicates an expected call of GetOnewayOutbound

func (*MockClientConfigMockRecorder) GetUnaryOutbound added in v1.10.0

func (_mr *MockClientConfigMockRecorder) GetUnaryOutbound() *gomock.Call

GetUnaryOutbound indicates an expected call of GetUnaryOutbound

func (*MockClientConfigMockRecorder) Service added in v1.10.0

func (_mr *MockClientConfigMockRecorder) Service() *gomock.Call

Service indicates an expected call of Service

type MockClientConfigProvider

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

MockClientConfigProvider is a mock of ClientConfigProvider interface

func NewMockClientConfigProvider

func NewMockClientConfigProvider(ctrl *gomock.Controller) *MockClientConfigProvider

NewMockClientConfigProvider creates a new mock instance

func (*MockClientConfigProvider) ClientConfig

func (_m *MockClientConfigProvider) ClientConfig(_param0 string) transport.ClientConfig

ClientConfig mocks base method

func (*MockClientConfigProvider) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

type MockClientConfigProviderMockRecorder added in v1.10.0

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

MockClientConfigProviderMockRecorder is the mock recorder for MockClientConfigProvider

func (*MockClientConfigProviderMockRecorder) ClientConfig added in v1.10.0

func (_mr *MockClientConfigProviderMockRecorder) ClientConfig(arg0 interface{}) *gomock.Call

ClientConfig indicates an expected call of ClientConfig

type MockInbound

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

MockInbound is a mock of Inbound interface

func NewMockInbound

func NewMockInbound(ctrl *gomock.Controller) *MockInbound

NewMockInbound creates a new mock instance

func (*MockInbound) EXPECT

func (_m *MockInbound) EXPECT() *MockInboundMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockInbound) IsRunning

func (_m *MockInbound) IsRunning() bool

IsRunning mocks base method

func (*MockInbound) SetRouter

func (_m *MockInbound) SetRouter(_param0 transport.Router)

SetRouter mocks base method

func (*MockInbound) Start

func (_m *MockInbound) Start() error

Start mocks base method

func (*MockInbound) Stop

func (_m *MockInbound) Stop() error

Stop mocks base method

func (*MockInbound) Transports

func (_m *MockInbound) Transports() []transport.Transport

Transports mocks base method

type MockInboundMockRecorder added in v1.10.0

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

MockInboundMockRecorder is the mock recorder for MockInbound

func (*MockInboundMockRecorder) IsRunning added in v1.10.0

func (_mr *MockInboundMockRecorder) IsRunning() *gomock.Call

IsRunning indicates an expected call of IsRunning

func (*MockInboundMockRecorder) SetRouter added in v1.10.0

func (_mr *MockInboundMockRecorder) SetRouter(arg0 interface{}) *gomock.Call

SetRouter indicates an expected call of SetRouter

func (*MockInboundMockRecorder) Start added in v1.10.0

func (_mr *MockInboundMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start

func (*MockInboundMockRecorder) Stop added in v1.10.0

func (_mr *MockInboundMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop

func (*MockInboundMockRecorder) Transports added in v1.10.0

func (_mr *MockInboundMockRecorder) Transports() *gomock.Call

Transports indicates an expected call of Transports

type MockOnewayHandler

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

MockOnewayHandler is a mock of OnewayHandler interface

func NewMockOnewayHandler

func NewMockOnewayHandler(ctrl *gomock.Controller) *MockOnewayHandler

NewMockOnewayHandler creates a new mock instance

func (*MockOnewayHandler) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockOnewayHandler) HandleOneway

func (_m *MockOnewayHandler) HandleOneway(_param0 context.Context, _param1 *transport.Request) error

HandleOneway mocks base method

type MockOnewayHandlerMockRecorder added in v1.10.0

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

MockOnewayHandlerMockRecorder is the mock recorder for MockOnewayHandler

func (*MockOnewayHandlerMockRecorder) HandleOneway added in v1.10.0

func (_mr *MockOnewayHandlerMockRecorder) HandleOneway(arg0, arg1 interface{}) *gomock.Call

HandleOneway indicates an expected call of HandleOneway

type MockOnewayOutbound

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

MockOnewayOutbound is a mock of OnewayOutbound interface

func NewMockOnewayOutbound

func NewMockOnewayOutbound(ctrl *gomock.Controller) *MockOnewayOutbound

NewMockOnewayOutbound creates a new mock instance

func (*MockOnewayOutbound) CallOneway

func (_m *MockOnewayOutbound) CallOneway(_param0 context.Context, _param1 *transport.Request) (transport.Ack, error)

CallOneway mocks base method

func (*MockOnewayOutbound) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockOnewayOutbound) IsRunning

func (_m *MockOnewayOutbound) IsRunning() bool

IsRunning mocks base method

func (*MockOnewayOutbound) Start

func (_m *MockOnewayOutbound) Start() error

Start mocks base method

func (*MockOnewayOutbound) Stop

func (_m *MockOnewayOutbound) Stop() error

Stop mocks base method

func (*MockOnewayOutbound) Transports

func (_m *MockOnewayOutbound) Transports() []transport.Transport

Transports mocks base method

type MockOnewayOutboundMockRecorder added in v1.10.0

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

MockOnewayOutboundMockRecorder is the mock recorder for MockOnewayOutbound

func (*MockOnewayOutboundMockRecorder) CallOneway added in v1.10.0

func (_mr *MockOnewayOutboundMockRecorder) CallOneway(arg0, arg1 interface{}) *gomock.Call

CallOneway indicates an expected call of CallOneway

func (*MockOnewayOutboundMockRecorder) IsRunning added in v1.10.0

func (_mr *MockOnewayOutboundMockRecorder) IsRunning() *gomock.Call

IsRunning indicates an expected call of IsRunning

func (*MockOnewayOutboundMockRecorder) Start added in v1.10.0

Start indicates an expected call of Start

func (*MockOnewayOutboundMockRecorder) Stop added in v1.10.0

Stop indicates an expected call of Stop

func (*MockOnewayOutboundMockRecorder) Transports added in v1.10.0

func (_mr *MockOnewayOutboundMockRecorder) Transports() *gomock.Call

Transports indicates an expected call of Transports

type MockRouteTable

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

MockRouteTable is a mock of RouteTable interface

func NewMockRouteTable

func NewMockRouteTable(ctrl *gomock.Controller) *MockRouteTable

NewMockRouteTable creates a new mock instance

func (*MockRouteTable) Choose

func (_m *MockRouteTable) Choose(_param0 context.Context, _param1 *transport.Request) (transport.HandlerSpec, error)

Choose mocks base method

func (*MockRouteTable) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockRouteTable) Procedures

func (_m *MockRouteTable) Procedures() []transport.Procedure

Procedures mocks base method

func (*MockRouteTable) Register

func (_m *MockRouteTable) Register(_param0 []transport.Procedure)

Register mocks base method

type MockRouteTableMockRecorder added in v1.10.0

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

MockRouteTableMockRecorder is the mock recorder for MockRouteTable

func (*MockRouteTableMockRecorder) Choose added in v1.10.0

func (_mr *MockRouteTableMockRecorder) Choose(arg0, arg1 interface{}) *gomock.Call

Choose indicates an expected call of Choose

func (*MockRouteTableMockRecorder) Procedures added in v1.10.0

func (_mr *MockRouteTableMockRecorder) Procedures() *gomock.Call

Procedures indicates an expected call of Procedures

func (*MockRouteTableMockRecorder) Register added in v1.10.0

func (_mr *MockRouteTableMockRecorder) Register(arg0 interface{}) *gomock.Call

Register indicates an expected call of Register

type MockRouter

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

MockRouter is a mock of Router interface

func NewMockRouter

func NewMockRouter(ctrl *gomock.Controller) *MockRouter

NewMockRouter creates a new mock instance

func (*MockRouter) Choose

func (_m *MockRouter) Choose(_param0 context.Context, _param1 *transport.Request) (transport.HandlerSpec, error)

Choose mocks base method

func (*MockRouter) EXPECT

func (_m *MockRouter) EXPECT() *MockRouterMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockRouter) Procedures

func (_m *MockRouter) Procedures() []transport.Procedure

Procedures mocks base method

type MockRouterMockRecorder added in v1.10.0

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

MockRouterMockRecorder is the mock recorder for MockRouter

func (*MockRouterMockRecorder) Choose added in v1.10.0

func (_mr *MockRouterMockRecorder) Choose(arg0, arg1 interface{}) *gomock.Call

Choose indicates an expected call of Choose

func (*MockRouterMockRecorder) Procedures added in v1.10.0

func (_mr *MockRouterMockRecorder) Procedures() *gomock.Call

Procedures indicates an expected call of Procedures

type MockTransport added in v1.7.0

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

MockTransport is a mock of Transport interface

func NewMockTransport added in v1.7.0

func NewMockTransport(ctrl *gomock.Controller) *MockTransport

NewMockTransport creates a new mock instance

func (*MockTransport) EXPECT added in v1.7.0

EXPECT returns an object that allows the caller to indicate expected use

func (*MockTransport) IsRunning added in v1.7.0

func (_m *MockTransport) IsRunning() bool

IsRunning mocks base method

func (*MockTransport) Start added in v1.7.0

func (_m *MockTransport) Start() error

Start mocks base method

func (*MockTransport) Stop added in v1.7.0

func (_m *MockTransport) Stop() error

Stop mocks base method

type MockTransportMockRecorder added in v1.10.0

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

MockTransportMockRecorder is the mock recorder for MockTransport

func (*MockTransportMockRecorder) IsRunning added in v1.10.0

func (_mr *MockTransportMockRecorder) IsRunning() *gomock.Call

IsRunning indicates an expected call of IsRunning

func (*MockTransportMockRecorder) Start added in v1.10.0

func (_mr *MockTransportMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start

func (*MockTransportMockRecorder) Stop added in v1.10.0

func (_mr *MockTransportMockRecorder) Stop() *gomock.Call

Stop indicates an expected call of Stop

type MockUnaryHandler

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

MockUnaryHandler is a mock of UnaryHandler interface

func NewMockUnaryHandler

func NewMockUnaryHandler(ctrl *gomock.Controller) *MockUnaryHandler

NewMockUnaryHandler creates a new mock instance

func (*MockUnaryHandler) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockUnaryHandler) Handle

func (_m *MockUnaryHandler) Handle(_param0 context.Context, _param1 *transport.Request, _param2 transport.ResponseWriter) error

Handle mocks base method

type MockUnaryHandlerMockRecorder added in v1.10.0

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

MockUnaryHandlerMockRecorder is the mock recorder for MockUnaryHandler

func (*MockUnaryHandlerMockRecorder) Handle added in v1.10.0

func (_mr *MockUnaryHandlerMockRecorder) Handle(arg0, arg1, arg2 interface{}) *gomock.Call

Handle indicates an expected call of Handle

type MockUnaryOutbound

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

MockUnaryOutbound is a mock of UnaryOutbound interface

func NewMockUnaryOutbound

func NewMockUnaryOutbound(ctrl *gomock.Controller) *MockUnaryOutbound

NewMockUnaryOutbound creates a new mock instance

func (*MockUnaryOutbound) Call

func (_m *MockUnaryOutbound) Call(_param0 context.Context, _param1 *transport.Request) (*transport.Response, error)

Call mocks base method

func (*MockUnaryOutbound) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockUnaryOutbound) IsRunning

func (_m *MockUnaryOutbound) IsRunning() bool

IsRunning mocks base method

func (*MockUnaryOutbound) Start

func (_m *MockUnaryOutbound) Start() error

Start mocks base method

func (*MockUnaryOutbound) Stop

func (_m *MockUnaryOutbound) Stop() error

Stop mocks base method

func (*MockUnaryOutbound) Transports

func (_m *MockUnaryOutbound) Transports() []transport.Transport

Transports mocks base method

type MockUnaryOutboundMockRecorder added in v1.10.0

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

MockUnaryOutboundMockRecorder is the mock recorder for MockUnaryOutbound

func (*MockUnaryOutboundMockRecorder) Call added in v1.10.0

func (_mr *MockUnaryOutboundMockRecorder) Call(arg0, arg1 interface{}) *gomock.Call

Call indicates an expected call of Call

func (*MockUnaryOutboundMockRecorder) IsRunning added in v1.10.0

func (_mr *MockUnaryOutboundMockRecorder) IsRunning() *gomock.Call

IsRunning indicates an expected call of IsRunning

func (*MockUnaryOutboundMockRecorder) Start added in v1.10.0

Start indicates an expected call of Start

func (*MockUnaryOutboundMockRecorder) Stop added in v1.10.0

Stop indicates an expected call of Stop

func (*MockUnaryOutboundMockRecorder) Transports added in v1.10.0

func (_mr *MockUnaryOutboundMockRecorder) Transports() *gomock.Call

Transports indicates an expected call of Transports

type RequestMatcher

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

RequestMatcher may be used in gomock argument lists to assert that two requests match.

Requests are considered to be matching if: all their primitive parameters match, the headers of the received request include all the headers from the source request, and the contents of the request bodies are the same.

func NewRequestMatcher

func NewRequestMatcher(t *testing.T, r *transport.Request) RequestMatcher

NewRequestMatcher constructs a new RequestMatcher from the given testing.T and request.

The request's contents are read in their entirety and replaced with a bytes.Reader.

func (RequestMatcher) Matches

func (m RequestMatcher) Matches(got interface{}) bool

Matches checks if the given object matches the Request provided in NewRequestMatcher.

func (RequestMatcher) String

func (m RequestMatcher) String() string

type ResponseMatcher

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

ResponseMatcher is similar to RequestMatcher but for responses.

func NewResponseMatcher

func NewResponseMatcher(t *testing.T, r *transport.Response) ResponseMatcher

NewResponseMatcher builds a new ResponseMatcher that verifies that responses match the given Response.

func (ResponseMatcher) Matches

func (m ResponseMatcher) Matches(got interface{}) bool

Matches checks if the given object matches the Response provided in NewResponseMatcher.

Jump to

Keyboard shortcuts

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