Documentation ¶
Overview ¶
Package api is for all interfaces and patterns that need to be implemented to interact with the yarpctest api, but not the explicit types we'll use to make requests, or the types that we'll use directly in tests.
The purpose of this sub-package is to reduce the information that needs to be provided at the top-level yarpctest package.
Index ¶
- func Run(name string, t testing.TB, f func(testing.TB))
- type Action
- type ActionFunc
- type HandlerOption
- type HandlerOptionFunc
- type HandlerOpts
- type Lifecycle
- type NoopLifecycle
- type NoopStop
- type ProcOption
- type ProcOpts
- type RequestOption
- type RequestOptionFunc
- type RequestOpts
- type SafeTestingTB
- type SafeTestingTBOnStart
- type ServiceOption
- type ServiceOptionFunc
- type ServiceOpts
- type UnaryHandler
- type UnaryHandlerFunc
- type UnaryInboundMiddleware
- type UnaryInboundMiddlewareFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
Action defines an object that can be "Run" to assert things against the world through action.
type ActionFunc ¶
ActionFunc is a helper to convert a function to implement the Action interface
type HandlerOption ¶
type HandlerOption interface { Lifecycle ApplyHandler(opts *HandlerOpts) }
HandlerOption defines options that can be passed into a handler.
type HandlerOptionFunc ¶
type HandlerOptionFunc func(opts *HandlerOpts)
HandlerOptionFunc converts a function into a HandlerOption.
func (HandlerOptionFunc) ApplyHandler ¶
func (f HandlerOptionFunc) ApplyHandler(opts *HandlerOpts)
ApplyHandler implements HandlerOption.
type HandlerOpts ¶
type HandlerOpts struct {
Handlers []UnaryHandler
}
HandlerOpts are configuration options for a series of handlers.
type Lifecycle ¶
Lifecycle defines test infra that needs to be started before the actions and stopped afterwards.
type NoopLifecycle ¶
type NoopLifecycle struct{}
NoopLifecycle is a convenience struct that can be embedded to make a struct implement the Start and Stop methods of Lifecycle.
type NoopStop ¶
type NoopStop struct{}
NoopStop is a convenience struct that can be embedded to make a struct implement the Stop method of Lifecycle.
type ProcOption ¶
ProcOption defines the options that can be applied to a procedure.
type ProcOpts ¶
type ProcOpts struct { Name string HandlerSpec transport.HandlerSpec }
ProcOpts are configuration options for a procedure.
type RequestOption ¶
type RequestOption interface {
ApplyRequest(*RequestOpts)
}
RequestOption can be used to configure a request.
type RequestOptionFunc ¶
type RequestOptionFunc func(*RequestOpts)
RequestOptionFunc converts a function into a RequestOption.
func (RequestOptionFunc) ApplyRequest ¶
func (f RequestOptionFunc) ApplyRequest(opts *RequestOpts)
ApplyRequest implements RequestOption.
type RequestOpts ¶
type RequestOpts struct { Port uint16 GiveRequest *transport.Request WantResponse *transport.Response WantError error }
RequestOpts are configuration options for a yarpc Request and assertions to make on the response.
func NewRequestOpts ¶
func NewRequestOpts() RequestOpts
NewRequestOpts initializes a RequestOpts struct.
type SafeTestingTB ¶
SafeTestingTB is a struct that wraps a testing.TB in a mutex for safe concurrent usage.
func (*SafeTestingTB) GetTestingTB ¶
func (s *SafeTestingTB) GetTestingTB() testing.TB
GetTestingTB safely gets the testing.TB for the testable.
func (*SafeTestingTB) SetTestingTB ¶
func (s *SafeTestingTB) SetTestingTB(t testing.TB)
SetTestingTB safely sets the testing.TB.
type SafeTestingTBOnStart ¶
type SafeTestingTBOnStart struct {
SafeTestingTB
}
SafeTestingTBOnStart is an embeddable struct that automatically grabs testing.TB objects on "Start" for lifecycles.
type ServiceOption ¶
type ServiceOption interface { Lifecycle ApplyService(*ServiceOpts) }
ServiceOption is an option when creating a Service.
type ServiceOptionFunc ¶
type ServiceOptionFunc func(*ServiceOpts)
ServiceOptionFunc converts a function into a ServiceOption.
func (ServiceOptionFunc) ApplyService ¶
func (f ServiceOptionFunc) ApplyService(opts *ServiceOpts)
ApplyService implements ServiceOption.
type ServiceOpts ¶
type ServiceOpts struct { Name string Listener net.Listener Port uint16 Procedures []transport.Procedure }
ServiceOpts are the configuration options for a yarpc service.
type UnaryHandler ¶
type UnaryHandler interface { Lifecycle transport.UnaryHandler }
UnaryHandler is a wrapper around the transport.UnaryInbound and Lifecycle interfaces.
type UnaryHandlerFunc ¶
UnaryHandlerFunc converts a function into a transport.UnaryHandler.
func (UnaryHandlerFunc) Handle ¶
func (f UnaryHandlerFunc) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter) error
Handle implements yarpc/api/transport#UnaryHandler.
type UnaryInboundMiddleware ¶
type UnaryInboundMiddleware interface { Lifecycle middleware.UnaryInbound }
UnaryInboundMiddleware is a wrapper around the middleware.UnaryInbound and Lifecycle interfaces.
type UnaryInboundMiddlewareFunc ¶
type UnaryInboundMiddlewareFunc func(context.Context, *transport.Request, transport.ResponseWriter, transport.UnaryHandler) error
UnaryInboundMiddlewareFunc converts a function into a transport.UnaryInboundMiddleware.
func (UnaryInboundMiddlewareFunc) Handle ¶
func (f UnaryInboundMiddlewareFunc) Handle(ctx context.Context, req *transport.Request, resw transport.ResponseWriter, h transport.UnaryHandler) error
Handle implements yarpc/api/transport#UnaryInboundMiddleware.