Documentation
¶
Overview ¶
Package matchers is a set of matchers used with Gomock. They're all implementing the gomock.Matcher interface.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AsyncBlockMatcher ¶
type AsyncBlockMatcher struct {
// contains filtered or unexported fields
}
func AsyncBlock ¶
func AsyncBlock(matcher gomock.Matcher) *AsyncBlockMatcher
AsyncBlock returns a matcher holding a channel which will be signaled when the `Matches` function is called. AsyncBlock will wrap any other matcher to do the actual matching.
This is useful if the code you're testing is spawning a go function which will invoke your mock at some time in the future. The channel gives you an easy way to wait for that invokation (using `<- matcher.Channel()`) and then do assertions.
func (*AsyncBlockMatcher) Channel ¶
func (m *AsyncBlockMatcher) Channel() <-chan struct{}
Channel returns a channel which will have an empty struct written to it every time `Matches` is invoked.
func (*AsyncBlockMatcher) Matches ¶
func (m *AsyncBlockMatcher) Matches(x interface{}) bool
func (*AsyncBlockMatcher) String ¶
func (m *AsyncBlockMatcher) String() string
type ProtoMatcher ¶
type ProtoMatcher struct {
// contains filtered or unexported fields
}
func (*ProtoMatcher) Matches ¶
func (p *ProtoMatcher) Matches(x interface{}) bool
func (*ProtoMatcher) String ¶
func (p *ProtoMatcher) String() string
type RecordMatcher ¶
type RecordMatcher struct {
// contains filtered or unexported fields
}
func Record ¶
func Record(m gomock.Matcher) *RecordMatcher
Record returns a new matcher which wraps the provided matcher - following all the matching rules of that matcher. In addition, the argument which is matched is recorded and can later be retrieved for inspection using the Get() func
func (*RecordMatcher) Get ¶
func (rm *RecordMatcher) Get() interface{}
func (*RecordMatcher) Matches ¶
func (rm *RecordMatcher) Matches(x interface{}) bool
func (*RecordMatcher) String ¶
func (rm *RecordMatcher) String() string
type RegexpMatcher ¶
type RegexpMatcher struct {
// contains filtered or unexported fields
}
func Regexp ¶
func Regexp(pattern string) *RegexpMatcher
func (*RegexpMatcher) Matches ¶
func (m *RegexpMatcher) Matches(x interface{}) bool
func (*RegexpMatcher) String ¶
func (m *RegexpMatcher) String() string
type SameMatcher ¶
type SameMatcher struct {
// contains filtered or unexported fields
}
func Same ¶
func Same(x interface{}) *SameMatcher
Same will return a new Same matcher which uses `==` comparison
func (*SameMatcher) Matches ¶
func (m *SameMatcher) Matches(x interface{}) bool
func (*SameMatcher) String ¶
func (m *SameMatcher) String() string
type SliceLengthMatcher ¶ added in v2.2.0
type SliceLengthMatcher[T any] struct { // contains filtered or unexported fields }
func (*SliceLengthMatcher[T]) Matches ¶ added in v2.2.0
func (s *SliceLengthMatcher[T]) Matches(x interface{}) bool
func (*SliceLengthMatcher[T]) String ¶ added in v2.2.0
func (s *SliceLengthMatcher[T]) String() string