transporttest

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2016 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTTLDelta = 20 * 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 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 MockChannel added in v0.4.0

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

Mock of Channel interface

func NewMockChannel added in v0.4.0

func NewMockChannel(ctrl *gomock.Controller) *MockChannel

func (*MockChannel) Caller added in v0.4.0

func (_m *MockChannel) Caller() string

func (*MockChannel) EXPECT added in v0.4.0

func (_m *MockChannel) EXPECT() *_MockChannelRecorder

func (*MockChannel) GetOnewayOutbound added in v0.4.0

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

func (*MockChannel) GetUnaryOutbound added in v0.4.0

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

func (*MockChannel) Service added in v0.4.0

func (_m *MockChannel) Service() string

type MockChannelProvider added in v0.4.0

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

Mock of ChannelProvider interface

func NewMockChannelProvider added in v0.4.0

func NewMockChannelProvider(ctrl *gomock.Controller) *MockChannelProvider

func (*MockChannelProvider) Channel added in v0.4.0

func (_m *MockChannelProvider) Channel(_param0 string) transport.Channel

func (*MockChannelProvider) EXPECT added in v0.4.0

func (_m *MockChannelProvider) EXPECT() *_MockChannelProviderRecorder

type MockInbound

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

Mock of Inbound interface

func NewMockInbound

func NewMockInbound(ctrl *gomock.Controller) *MockInbound

func (*MockInbound) EXPECT

func (_m *MockInbound) EXPECT() *_MockInboundRecorder

func (*MockInbound) Start

func (_m *MockInbound) Start(_param0 transport.ServiceDetail, _param1 transport.Deps) error

func (*MockInbound) Stop

func (_m *MockInbound) Stop() error

type MockOnewayHandler

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

Mock of OnewayHandler interface

func NewMockOnewayHandler

func NewMockOnewayHandler(ctrl *gomock.Controller) *MockOnewayHandler

func (*MockOnewayHandler) EXPECT

func (_m *MockOnewayHandler) EXPECT() *_MockOnewayHandlerRecorder

func (*MockOnewayHandler) HandleOneway

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

type MockOnewayOutbound added in v0.4.0

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

Mock of OnewayOutbound interface

func NewMockOnewayOutbound added in v0.4.0

func NewMockOnewayOutbound(ctrl *gomock.Controller) *MockOnewayOutbound

func (*MockOnewayOutbound) CallOneway added in v0.4.0

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

func (*MockOnewayOutbound) EXPECT added in v0.4.0

func (_m *MockOnewayOutbound) EXPECT() *_MockOnewayOutboundRecorder

func (*MockOnewayOutbound) Start added in v0.4.0

func (_m *MockOnewayOutbound) Start(_param0 transport.Deps) error

func (*MockOnewayOutbound) Stop added in v0.4.0

func (_m *MockOnewayOutbound) Stop() error

type MockRegistry added in v0.4.0

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

Mock of Registry interface

func NewMockRegistry added in v0.4.0

func NewMockRegistry(ctrl *gomock.Controller) *MockRegistry

func (*MockRegistry) Choose added in v0.5.0

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

func (*MockRegistry) EXPECT added in v0.4.0

func (_m *MockRegistry) EXPECT() *_MockRegistryRecorder

func (*MockRegistry) ServiceProcedures added in v0.4.0

func (_m *MockRegistry) ServiceProcedures() []transport.ServiceProcedure

type MockUnaryHandler added in v0.4.0

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

Mock of UnaryHandler interface

func NewMockUnaryHandler added in v0.4.0

func NewMockUnaryHandler(ctrl *gomock.Controller) *MockUnaryHandler

func (*MockUnaryHandler) EXPECT added in v0.4.0

func (_m *MockUnaryHandler) EXPECT() *_MockUnaryHandlerRecorder

func (*MockUnaryHandler) Handle added in v0.4.0

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

type MockUnaryOutbound added in v0.4.0

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

Mock of UnaryOutbound interface

func NewMockUnaryOutbound added in v0.4.0

func NewMockUnaryOutbound(ctrl *gomock.Controller) *MockUnaryOutbound

func (*MockUnaryOutbound) Call added in v0.4.0

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

func (*MockUnaryOutbound) EXPECT added in v0.4.0

func (_m *MockUnaryOutbound) EXPECT() *_MockUnaryOutboundRecorder

func (*MockUnaryOutbound) Start added in v0.4.0

func (_m *MockUnaryOutbound) Start(_param0 transport.Deps) error

func (*MockUnaryOutbound) Stop added in v0.4.0

func (_m *MockUnaryOutbound) Stop() error

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. It may include extra headers.
  • 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