Documentation
¶
Overview ¶
Package mock holds what the gRPC and HTTP mock servers have in common: how failures are reported, and how many times an expectation may and must be matched. The servers themselves live beside the packages they stand in for, in go/grpc/mock_server and go/http/mock_server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cardinality ¶
type Cardinality struct {
// contains filtered or unexported fields
}
Cardinality tracks how many times an expectation may and must be matched. The zero value is not usable; construct it with NewCardinality, which matches an unlimited number of times and requires at least one match.
It is embedded in each server's expectation type, which re-declares Times and AnyTimes to return itself so that options stay chainable.
func NewCardinality ¶
func NewCardinality() Cardinality
NewCardinality returns a cardinality requiring at least one match, with no upper bound.
func (*Cardinality) AnyTimes ¶
func (c *Cardinality) AnyTimes()
AnyTimes lets the expectation match any number of times, including none.
func (*Cardinality) Exhausted ¶
func (c *Cardinality) Exhausted() bool
Exhausted reports whether the expectation has taken every match it was declared for, and so should be skipped in favour of later expectations on the same endpoint.
func (*Cardinality) Times ¶
func (c *Cardinality) Times(count int)
Times requires the expectation to be matched exactly count times.
func (*Cardinality) Verify ¶
func (c *Cardinality) Verify() string
Verify returns the reason the expectation was not satisfied, or an empty string.