transporttest

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2016 License: MIT Imports: 11 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 ContextBaggage

type ContextBaggage map[string]string

ContextBaggage requires that the Context have the given baggage associated with it.

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 MockHandler

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

Mock of Handler interface

func NewMockHandler

func NewMockHandler(ctrl *gomock.Controller) *MockHandler

func (*MockHandler) EXPECT

func (_m *MockHandler) EXPECT() *_MockHandlerRecorder

func (*MockHandler) Handle

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

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.Handler, _param1 transport.Deps) error

func (*MockInbound) Stop

func (_m *MockInbound) Stop() error

type MockOutbound

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

Mock of Outbound interface

func NewMockOutbound

func NewMockOutbound(ctrl *gomock.Controller) *MockOutbound

func (*MockOutbound) Call

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

func (*MockOutbound) EXPECT

func (_m *MockOutbound) EXPECT() *_MockOutboundRecorder

func (*MockOutbound) Options

func (_m *MockOutbound) Options() transport.Options

func (*MockOutbound) Start

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

func (*MockOutbound) Stop

func (_m *MockOutbound) 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