Documentation ¶
Index ¶
- type AlwaysMatcher
- type AndMatcher
- type BeAboveMatcher
- type BeBelowMatcher
- type BeClosedMatcher
- type BeFalseMatcher
- type BeNilMatcher
- type BeTrueMatcher
- type ChainMatcher
- type ContainMatcher
- type ContainSubstringMatcher
- type Differ
- type EndWithMatcher
- type EqualMatcher
- type FetchMatcher
- type HaveCapMatcher
- type HaveKeyMatcher
- type HaveLenMatcher
- type HaveOccurredMatcher
- type IsNilMatcher
- type MatchJSONMatcher
- type MatchRegexpMatcher
- type Matcher
- type NotMatcher
- type OrMatcher
- type PanicMatcher
- type ReceiveMatcher
- type ReceiveOpt
- type StartWithMatcher
- type ViaPollingMatcher
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlwaysMatcher ¶
AlwaysMatcher matches by polling the child matcher until it returns an error. It will return an error the first time the child matcher returns an error. If the child matcher never returns an error, then it will return a nil.
Duration is the longest scenario for the matcher if the child matcher continues to return nil
Interval is the period between polling.
func Always ¶
func Always(m Matcher) AlwaysMatcher
Always returns a default AlwaysMatcher. Length of 100ms and rate 10ms
func (AlwaysMatcher) Match ¶
func (m AlwaysMatcher) Match(actual interface{}) (interface{}, error)
Match takes a value that can change over time. Therefore, the only two valid options are a function with no arguments and a single return type, or a readable channel. Anything else will return an error.
If actual is a channel, then the child matcher will have to handle reading from the channel.
If the actual is a function, then the matcher will invoke the value and pass the returned value to the child matcher.
type AndMatcher ¶
type AndMatcher struct {
Children []Matcher
}
func And ¶
func And(a, b Matcher, ms ...Matcher) AndMatcher
func (AndMatcher) Match ¶
func (m AndMatcher) Match(actual interface{}) (interface{}, error)
type BeAboveMatcher ¶
type BeAboveMatcher struct {
// contains filtered or unexported fields
}
BeAboveMatcher accepts a float64. It succeeds if the actual is greater than the expected.
func BeAbove ¶
func BeAbove(expected float64) BeAboveMatcher
BeAbove returns a BeAboveMatcher with the expected value.
func (BeAboveMatcher) Match ¶
func (m BeAboveMatcher) Match(actual interface{}) (interface{}, error)
type BeBelowMatcher ¶
type BeBelowMatcher struct {
// contains filtered or unexported fields
}
BeBelowMatcher accepts a float64. It succeeds if the actual is less than the expected.
func BeBelow ¶
func BeBelow(expected float64) BeBelowMatcher
BeBelow returns a BeBelowMatcher with the expected value.
func (BeBelowMatcher) Match ¶
func (m BeBelowMatcher) Match(actual interface{}) (interface{}, error)
type BeClosedMatcher ¶
type BeClosedMatcher struct{}
BeClosedMatcher only accepts a readable channel. It will error for anything else. It will succeed if the channel is closed.
func (BeClosedMatcher) Match ¶
func (m BeClosedMatcher) Match(actual interface{}) (interface{}, error)
type BeFalseMatcher ¶
type BeFalseMatcher struct{}
BeFalseMatcher will succeed if actual is false.
func (BeFalseMatcher) Match ¶
func (m BeFalseMatcher) Match(actual interface{}) (interface{}, error)
type BeNilMatcher ¶
type BeNilMatcher struct{}
BeNilMatcher will succeed if actual is nil.
func (BeNilMatcher) Match ¶
func (m BeNilMatcher) Match(actual interface{}) (interface{}, error)
type BeTrueMatcher ¶
type BeTrueMatcher struct{}
BeTrueMatcher will succeed if actual is true.
func (BeTrueMatcher) Match ¶
func (m BeTrueMatcher) Match(actual interface{}) (interface{}, error)
type ChainMatcher ¶
type ChainMatcher struct {
Children []Matcher
}
func Chain ¶
func Chain(a, b Matcher, ms ...Matcher) ChainMatcher
func (ChainMatcher) Match ¶
func (m ChainMatcher) Match(actual interface{}) (interface{}, error)
type ContainMatcher ¶
type ContainMatcher struct {
// contains filtered or unexported fields
}
func Contain ¶
func Contain(values ...interface{}) ContainMatcher
func (ContainMatcher) Match ¶
func (m ContainMatcher) Match(actual interface{}) (interface{}, error)
type ContainSubstringMatcher ¶
type ContainSubstringMatcher struct {
// contains filtered or unexported fields
}
ContainSubstringMatcher accepts a string and succeeds if the actual string contains the expected string.
func ContainSubstring ¶
func ContainSubstring(substr string) ContainSubstringMatcher
ContainSubstring returns a ContainSubstringMatcher with the expected substring.
func (ContainSubstringMatcher) Match ¶
func (m ContainSubstringMatcher) Match(actual interface{}) (interface{}, error)
type Differ ¶
type Differ interface {
Diff(actual, expected interface{}) string
}
Differ is a type that can show a detailed difference between an actual and an expected value.
type EndWithMatcher ¶
type EndWithMatcher struct {
// contains filtered or unexported fields
}
EndWithMatcher accepts a string and succeeds if the actual string ends with the expected string.
func EndWith ¶
func EndWith(suffix string) EndWithMatcher
EndWith returns an EndWithMatcher with the expected suffix.
func (EndWithMatcher) Match ¶
func (m EndWithMatcher) Match(actual interface{}) (interface{}, error)
type EqualMatcher ¶
type EqualMatcher struct {
// contains filtered or unexported fields
}
EqualMatcher performs a DeepEqual between the actual and expected.
func Equal ¶
func Equal(expected interface{}) *EqualMatcher
Equal returns an EqualMatcher with the expected value
func (EqualMatcher) Match ¶
func (m EqualMatcher) Match(actual interface{}) (interface{}, error)
func (*EqualMatcher) UseDiffer ¶
func (m *EqualMatcher) UseDiffer(d Differ)
type FetchMatcher ¶
type FetchMatcher struct {
OutputTo interface{}
}
func Fetch ¶
func Fetch(outputTo interface{}) FetchMatcher
func (FetchMatcher) Match ¶
func (m FetchMatcher) Match(actual interface{}) (interface{}, error)
type HaveCapMatcher ¶
type HaveCapMatcher struct {
// contains filtered or unexported fields
}
This matcher works on Slices, Arrays, Maps and Channels and will succeed if the type has the specified capacity.
func HaveCap ¶
func HaveCap(expected int) HaveCapMatcher
HaveCap returns a HaveCapMatcher with the specified capacity
func (HaveCapMatcher) Match ¶
func (m HaveCapMatcher) Match(actual interface{}) (interface{}, error)
type HaveKeyMatcher ¶
type HaveKeyMatcher struct {
// contains filtered or unexported fields
}
HaveKeyMatcher accepts map types and will succeed if the map contains the specified key.
func HaveKey ¶
func HaveKey(key interface{}) HaveKeyMatcher
HaveKey returns a HaveKeyMatcher with the specified key.
func (HaveKeyMatcher) Match ¶
func (m HaveKeyMatcher) Match(actual interface{}) (interface{}, error)
type HaveLenMatcher ¶
type HaveLenMatcher struct {
// contains filtered or unexported fields
}
HaveLenMatcher accepts Strings, Slices, Arrays, Maps and Channels. It will succeed if the type has the specified length.
func HaveLen ¶
func HaveLen(expected int) HaveLenMatcher
HaveLen returns a HaveLenMatcher with the specified length.
func (HaveLenMatcher) Match ¶
func (m HaveLenMatcher) Match(actual interface{}) (interface{}, error)
type HaveOccurredMatcher ¶
type HaveOccurredMatcher struct { }
HaveOccurredMatcher will succeed if the actual value is a non-nil error.
func HaveOccurred ¶
func HaveOccurred() HaveOccurredMatcher
HaveOccurred returns a HaveOccurredMatcher
func (HaveOccurredMatcher) Match ¶
func (m HaveOccurredMatcher) Match(actual interface{}) (interface{}, error)
type IsNilMatcher ¶
type IsNilMatcher struct{}
IsNilMatcher will succeed if actual is nil.
func (IsNilMatcher) Match ¶
func (m IsNilMatcher) Match(actual interface{}) (interface{}, error)
type MatchJSONMatcher ¶
type MatchJSONMatcher struct {
// contains filtered or unexported fields
}
MatchJSONMatcher converts both expected and actual to a map[string]interface{} and does a reflect.DeepEqual between them
func MatchJSON ¶
func MatchJSON(expected interface{}) MatchJSONMatcher
MatchJSON returns an MatchJSONMatcher with the expected value
func (MatchJSONMatcher) Match ¶
func (m MatchJSONMatcher) Match(actual interface{}) (interface{}, error)
type MatchRegexpMatcher ¶
type MatchRegexpMatcher struct {
// contains filtered or unexported fields
}
func MatchRegexp ¶
func MatchRegexp(pattern string) MatchRegexpMatcher
func (MatchRegexpMatcher) Match ¶
func (m MatchRegexpMatcher) Match(actual interface{}) (interface{}, error)
type Matcher ¶
type Matcher interface {
Match(actual interface{}) (resultValue interface{}, err error)
}
Matcher is a type that matches expected against actuals.
type NotMatcher ¶
type NotMatcher struct {
// contains filtered or unexported fields
}
NotMatcher accepts a matcher and will succeed if the specified matcher fails.
func Not ¶
func Not(child Matcher) NotMatcher
Not returns a NotMatcher with the specified child matcher.
func (NotMatcher) Match ¶
func (m NotMatcher) Match(actual interface{}) (interface{}, error)
type PanicMatcher ¶
type PanicMatcher struct { }
PanicMatcher accepts a function. It succeeds if the function panics.
func (PanicMatcher) Match ¶
func (m PanicMatcher) Match(actual interface{}) (result interface{}, err error)
type ReceiveMatcher ¶
type ReceiveMatcher struct {
// contains filtered or unexported fields
}
ReceiveMatcher only accepts a readable channel. It will error for anything else. It will attempt to receive from the channel but will not block. It fails if the channel is closed.
func (ReceiveMatcher) Match ¶
func (m ReceiveMatcher) Match(actual interface{}) (interface{}, error)
type ReceiveOpt ¶
type ReceiveOpt func(ReceiveMatcher) ReceiveMatcher
ReceiveOpt is an option that can be passed to the ReceiveMatcher constructor.
func ReceiveWait ¶
func ReceiveWait(t time.Duration) ReceiveOpt
ReceiveWait is an option that makes the ReceiveMatcher wait for values for the provided duration before deciding that the channel failed to receive.
type StartWithMatcher ¶
type StartWithMatcher struct {
// contains filtered or unexported fields
}
StartWithMatcher accepts a string and succeeds if the actual string starts with the expected string.
func StartWith ¶
func StartWith(prefix string) StartWithMatcher
StartWith returns a StartWithMatcher with the expected prefix.
func (StartWithMatcher) Match ¶
func (m StartWithMatcher) Match(actual interface{}) (interface{}, error)
type ViaPollingMatcher ¶
ViaPollingMatcher matches by polling the child matcher until it returns a success. It will return success the first time the child matcher returns a success. If the child matcher never returns a nil, then it will return the last error.
Duration is the worst case scenario for the matcher if the child matcher continues to return an error
Interval is the period between polling.
func ViaPolling ¶
func ViaPolling(m Matcher) ViaPollingMatcher
ViaPolling returns the default ViaPollingMatcher. Length of 1s and Rate of 10ms
func (ViaPollingMatcher) Match ¶
func (m ViaPollingMatcher) Match(actual interface{}) (interface{}, error)
Match takes a value that can change over time. Therefore, the only two valid options are a function with no arguments and a single return type, or a readable channel. Anything else will return an error.
If actual is a channel, then the child matcher will have to handle reading from the channel.
If the actual is a function, then the matcher will invoke the value and pass the returned value to the child matcher.
Source Files ¶
- always.go
- and.go
- be_above.go
- be_below.go
- be_closed.go
- be_false.go
- be_nil.go
- be_true.go
- chain.go
- contain.go
- contain_sub_string.go
- differ.go
- end_with.go
- equal.go
- fetch.go
- have_cap.go
- have_key.go
- have_len.go
- have_occurred.go
- is_nil.go
- match_json.go
- match_regexp.go
- not.go
- or.go
- panic.go
- receive.go
- start_with.go
- via_polling.go