outboundtest

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2017 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OutboundEvent

type OutboundEvent struct {
	// context.Deadline validation
	WantTimeout       time.Duration
	WantTimeoutBounds time.Duration

	// transport.Request validation
	WantCaller          string
	WantService         string
	WantEncoding        transport.Encoding
	WantProcedure       string
	WantShardKey        string
	WantRoutingKey      string
	WantRoutingDelegate string
	WantHeaders         transport.Headers

	// WantBody validates the request's body
	// It is special because if it is not set, we will not exhaust the
	// request body's io.Reader, which could cause an error up the stack,
	// this is by design for edge test cases.
	WantBody string

	// Indicates that we should block until the context is `Done`
	WaitForTimeout bool

	// Attributes put into the transport.Response object.
	GiveError            error
	GiveApplicationError bool
	GiveRespHeaders      transport.Headers
	GiveRespBody         string
}

OutboundEvent is a struct to validate an individual call to an outbound. It has explicit checks for all request and timeout attributes, and it can return all the information needed from the request.

func (*OutboundEvent) Call

Call will validate a single call to the outbound event based on the OutboundEvent's parameters.

type OutboundEventCallable

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

OutboundEventCallable is an object that can be used in conjunction with a yarpctest.FakeOutbound to create Fake functionality for an outbound through OutboundEvents. Every call to `OutboundEventCallable.Call` will be sent to an event in the OutboundEventCallable's event list. We will atomically increment the event index every time a request is sent, and we will fail the test if too many or too few requests were called.

func NewOutboundEventCallable

func NewOutboundEventCallable(t require.TestingT, events []*OutboundEvent) *OutboundEventCallable

NewOutboundEventCallable sets up an OutboundEventCallable.

func (*OutboundEventCallable) Call

Call implements the yarpctest.OutboundCallable function signature. It will send all requests to the appropriate event registered in the event slice.

func (*OutboundEventCallable) Cleanup

func (c *OutboundEventCallable) Cleanup()

Cleanup validates that all events in the OutboundEventCallable were called before we finished the test.

Jump to

Keyboard shortcuts

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