Documentation ¶
Overview ¶
Package weavetest provides mocks and functions that makes testing weave functionality easier.
Before adding a new code to this package make sure that it is used in at least two packages. Mocks and helpers that are utilized by only one package should be kept in that package.
Index ¶
- func Decorate(h weave.Handler, d weave.Decorator) weave.Handler
- func NewCondition() weave.Condition
- func NewKey() crypto.Signer
- func SequenceID(n uint64) []byte
- type Auth
- type CtxAuth
- type Decorator
- func (d *Decorator) CallCount() int
- func (d *Decorator) Check(ctx weave.Context, db weave.KVStore, tx weave.Tx, next weave.Checker) (weave.CheckResult, error)
- func (d *Decorator) CheckCallCount() int
- func (d *Decorator) Deliver(ctx weave.Context, db weave.KVStore, tx weave.Tx, next weave.Deliverer) (weave.DeliverResult, error)
- func (d *Decorator) DeliverCallCount() int
- type Handler
- func (h *Handler) CallCount() int
- func (h *Handler) Check(ctx weave.Context, db weave.KVStore, tx weave.Tx) (weave.CheckResult, error)
- func (h *Handler) CheckCallCount() int
- func (h *Handler) Deliver(ctx weave.Context, db weave.KVStore, tx weave.Tx) (weave.DeliverResult, error)
- func (h *Handler) DeliverCallCount() int
- type Msg
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCondition ¶
NewCondition returns a newly generated unique weave condition. To create a weave address call Address method of returned condition.
func SequenceID ¶
SequenceID returns an ID encoded as if it was generated by the bucket sequence call. This function is helpful for testing sequential event processing and objects creation where the ID of the next saved entity can be determined.
Types ¶
type Auth ¶
type Auth struct { // Signer represents an authentication of a single signer. This is a // convinience attribute when creating an authentication method for a // single signer. // When authenticating all signers declared on this structure are // considered. Signer weave.Condition // Signers represents an authentication of multiple signers. Signers []weave.Condition }
Auth is a mock implementing x.Authenticator interface.
This structure authenticates any of referenced conditions. You can use either Signer or Signers (or both) attributes to reference conditions. This is for the convinience and each time all signers (regardless which attribute) are considered.
type CtxAuth ¶
type CtxAuth struct { // Key used to set and retrieve conditions from the context. For // convinience only string type keys are allowed. Key string }
CtxAuth is a mock implementing x.Authenticator interface.
This implementation is using context to store and retrieve permissions.
func (*CtxAuth) GetConditions ¶
func (*CtxAuth) HasAddress ¶
type Decorator ¶
type Decorator struct { // CheckErr if set is returned by the Check method before calling // the wrapped handler. CheckErr error // DeliverErr if set is returned by the Deliver method before calling // the wrapped handler. DeliverErr error // contains filtered or unexported fields }
Decorator is a mock implementation of the weave.Decorator interface.
Set CheckErr or DeliverErr to force error response for corresponding method. If error attributes are not set then wrapped handler method is called and its result returned. Each method call is counted. Regardless of the method call result the counter is incremented.
func (*Decorator) CheckCallCount ¶
func (*Decorator) DeliverCallCount ¶
type Handler ¶
type Handler struct { // CheckResult is returned by Check method. CheckResult weave.CheckResult // CheckErr if set is returned by Check method. CheckErr error // DeliverResult is returned by Deliver method. DeliverResult weave.DeliverResult // DeliverErr if set is returned by Deliver method. DeliverErr error // contains filtered or unexported fields }
Handler implements a mock of weave.Handler
Use this handler in your tests. Set XxxResult and XxxErr to control what Xxx method call returns. Each method call is counted.
func (*Handler) CheckCallCount ¶
func (*Handler) DeliverCallCount ¶
type Msg ¶
type Msg struct { // Path returned by the path method, consumed by the router. RoutePath string // Serialized represents the serialized form of this message. Serialized []byte // Err if set is returned by any method call. Err error }
Msg represents a weave message. Message is a request processed by weave within a single transaction.