Back to godoc.org

Package yarpctest

v1.42.1
Latest Go to latest
Published: Dec 2, 2019 | License: MIT | Module: github.com/yarpc/yarpc-go

Index

Package Files

func Actions

func Actions(actions ...api.Action) api.Action

Actions will wrap a list of actions in a sequential executor.

func Body

func Body(msg string) api.RequestOption

Body sets the body on a request to the raw representation of the msg field.

func ClientStreamActions

func ClientStreamActions(actions ...api.ClientStreamAction) api.ClientStreamRequestOption

ClientStreamActions combines a series of client stream actions into actions that will be applied when the StreamRequest is run.

func CloseStream

func CloseStream() api.ClientStreamAction

CloseStream is an action to close a client stream.

func ConcurrentAction

func ConcurrentAction(action Action, threads int) api.Action

ConcurrentAction will call the provided action in n concurrent threads at the same time.

func EchoHandler

func EchoHandler(mw ...api.UnaryInboundMiddleware) *types.UnaryHandler

EchoHandler is a Unary Handler that will echo the body of the request into the response.

func EchoHandlerWithPrefix

func EchoHandlerWithPrefix(prefix string, mw ...api.UnaryInboundMiddleware) *types.UnaryHandler

EchoHandlerWithPrefix will echo the request it receives into the response, but, it will insert a prefix in front of the message.

func EchoStreamHandler

func EchoStreamHandler() api.ProcOption

EchoStreamHandler is a Bidirectional Stream Handler that will echo any request that is sent to it.

func ErrorHandler

func ErrorHandler(err error, mw ...api.UnaryInboundMiddleware) *types.UnaryHandler

ErrorHandler will always return an Error.

func GRPCRequest

func GRPCRequest(options ...api.RequestOption) api.Action

GRPCRequest creates a new grpc unary request.

func GRPCService

func GRPCService(options ...api.ServiceOption) api.Lifecycle

GRPCService will create a runnable GRPC service.

func GRPCStreamRequest

func GRPCStreamRequest(options ...api.ClientStreamRequestOption) api.Action

GRPCStreamRequest creates a new grpc stream request.

func GiveAndWantLargeBodyIsEchoed

func GiveAndWantLargeBodyIsEchoed(numOfBytes int) api.RequestOption

GiveAndWantLargeBodyIsEchoed creates an extremely large random byte buffer and validates that the body is echoed back to the response.

func GiveTimeout

func GiveTimeout(duration time.Duration) api.RequestOption

GiveTimeout will set the timeout for the request.

func HTTPRequest

func HTTPRequest(options ...api.RequestOption) api.Action

HTTPRequest creates a new YARPC http request.

func HTTPService

func HTTPService(options ...api.ServiceOption) api.Lifecycle

HTTPService will create a runnable HTTP service.

func Lifecycles

func Lifecycles(l ...api.Lifecycle) api.Lifecycle

Lifecycles is a wrapper around a list of Lifecycle definitions.

func Name

func Name(name string) *types.Name

Name is a shared option across services and procedures. It can be used as input in the constructor of both types.

func NewPortProvider

func NewPortProvider(t testing.TB) *types.PortProvider

NewPortProvider creates an object that can be used to synchronize ports in yarpctest infrastructure. Ports can be acquired through the "Port" function which will create new ports for the test based on the id passed into the function.

func OrderedRequestHandler

func OrderedRequestHandler(options ...api.HandlerOption) *types.OrderedHandler

OrderedRequestHandler will execute a series of Handlers in the order they are passed in. If the number of requests does not match, it will return an unknown error.

func OrderedStreamHandler

func OrderedStreamHandler(actions ...api.ServerStreamAction) api.ProcOption

OrderedStreamHandler is a bidirectional stream handler that can apply stream actions in a specified order.

func Port

func Port(port uint16) *types.Port

Port is a shared option across services and requests. It can be embedded in the constructor of both types.

func Proc

func Proc(options ...api.ProcOption) api.ServiceOption

Proc will create a new Procedure that can be included in a Service.

func Procedure

func Procedure(procedure string) *types.Procedure

Procedure specifies the "procedure" header for a request. It is a shared option across different requests.

func RecvStreamErr

func RecvStreamErr(wantErrMsgs ...string) *types.RecvStreamMsg

RecvStreamErr waits to receive a message on a client stream. It expects an error.

func RecvStreamMsg

func RecvStreamMsg(wantMsg string) *types.RecvStreamMsg

RecvStreamMsg waits to receive a message on a client stream.

func RepeatAction

func RepeatAction(action Action, times int) api.Action

RepeatAction will call the provided action a set number of times (the action must be idempotent).

func Retry

func Retry(count int, interval time.Duration) api.RequestOption

Retry retries the request for a given times, until the request succeeds and the response matches.

func SendStreamDecodeErrorAndExpectError

func SendStreamDecodeErrorAndExpectError(decodeErr error, wantErrMsgs ...string) *types.SendStreamMsg

SendStreamDecodeErrorAndExpectError induces a decode error on the stream message and asserts on the result.

func SendStreamMsg

func SendStreamMsg(sendMsg string) *types.SendStreamMsg

SendStreamMsg sends a message to a stream.

func SendStreamMsgAndExpectError

func SendStreamMsgAndExpectError(sendMsg string, wantErrMsgs ...string) *types.SendStreamMsg

SendStreamMsgAndExpectError sends a message on a stream and asserts on the error returned.

func Service

func Service(service string) *types.Service

Service specifies the "service" header for a request. It is a shared option across different requests.

func ShardKey

func ShardKey(key string) *types.ShardKey

ShardKey specifies that "shard key" header for a request. It is a shared option across different requests.

func StaticHandler

func StaticHandler(msg string, mw ...api.UnaryInboundMiddleware) *types.UnaryHandler

StaticHandler will always return the same response.

func StreamHandlerError

func StreamHandlerError(err error) api.ServerStreamAction

StreamHandlerError is an action to return an error from a ServerStream handler.

func TChannelRequest

func TChannelRequest(options ...api.RequestOption) api.Action

TChannelRequest creates a new tchannel request.

func TChannelService

func TChannelService(options ...api.ServiceOption) api.Lifecycle

TChannelService will create a runnable TChannel service.

func UnaryOutboundMiddleware

func UnaryOutboundMiddleware(mw ...middleware.UnaryOutbound) api.RequestOption

UnaryOutboundMiddleware sets unary outbound middleware for a request.

Multiple invocations will append to existing middleware.

func WantError

func WantError(errMsg string) api.RequestOption

WantError creates an assertion on the request response to validate the error.

func WantHeader

func WantHeader(key, value string) *types.WantHeader

WantHeader will set up a header assertion for request/response headers.

func WantRespBody

func WantRespBody(body string) api.RequestOption

WantRespBody will assert that the response body matches at the end of the request.

func WantStreamError

func WantStreamError(wantErrMsgs ...string) api.ClientStreamRequestOption

WantStreamError asserts that the stream request had an error immediately.

func WithHeader

func WithHeader(key, value string) *types.GiveHeader

WithHeader will send headers for requests and responses.

type Action

type Action api.Action

Action is the interface for applying actions (Requests) in tests.

type Lifecycle

type Lifecycle api.Lifecycle

Lifecycle is the interface for creating/starting/stopping lifecycles (Services) in tests.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier