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 DifferUser
- 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 any) (any, 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
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.
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.
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.
type ChainMatcher ¶
type ChainMatcher struct { Children []Matcher // contains filtered or unexported fields }
func Chain ¶
func Chain(a, b Matcher, ms ...Matcher) *ChainMatcher
func (*ChainMatcher) UseDiffer ¶ added in v0.3.3
func (m *ChainMatcher) UseDiffer(d Differ)
type ContainMatcher ¶
type ContainMatcher struct {
// contains filtered or unexported fields
}
func Contain ¶
func Contain(values ...any) ContainMatcher
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.
type Differ ¶
Differ is a type that can show a detailed difference between an actual and an expected value.
type DifferUser ¶ added in v0.3.3
type DifferUser interface {
UseDiffer(Differ)
}
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.
type EqualMatcher ¶
type EqualMatcher struct {
// contains filtered or unexported fields
}
EqualMatcher performs a DeepEqual between the actual and expected.
func Equal ¶
func Equal(expected any) *EqualMatcher
Equal returns an EqualMatcher with the expected value
func (*EqualMatcher) UseDiffer ¶
func (m *EqualMatcher) UseDiffer(d Differ)
type FetchMatcher ¶
type FetchMatcher struct {
OutputTo any
}
func Fetch ¶
func Fetch(outputTo any) FetchMatcher
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
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 any) HaveKeyMatcher
HaveKey returns a HaveKeyMatcher with the specified key.
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.
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
type MatchJSONMatcher ¶
type MatchJSONMatcher struct {
// contains filtered or unexported fields
}
MatchJSONMatcher converts both expected and actual to a map[string]any and does a reflect.DeepEqual between them
func MatchJSON ¶
func MatchJSON(expected any) MatchJSONMatcher
MatchJSON returns an MatchJSONMatcher with the expected value
type MatchRegexpMatcher ¶
type MatchRegexpMatcher struct {
// contains filtered or unexported fields
}
func MatchRegexp ¶
func MatchRegexp(pattern string) MatchRegexpMatcher
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.
type PanicMatcher ¶
type PanicMatcher struct { }
PanicMatcher accepts a function. It succeeds if the function panics.
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.
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.
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 any) (any, 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