mirror of
https://github.com/romdo/gomockctx.git
synced 2026-02-19 08:06:40 +00:00
refactor: improve code structure and add tests
This commit is contained in:
26
any.go
Normal file
26
any.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package gomockctx
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
// Any returns a gomock.Matcher which matches any context.Context object.
|
||||
func Any() gomock.Matcher {
|
||||
return &anyMatcher{}
|
||||
}
|
||||
|
||||
type anyMatcher struct{}
|
||||
|
||||
var _ gomock.Matcher = &anyMatcher{}
|
||||
|
||||
func (cm *anyMatcher) Matches(x interface{}) bool {
|
||||
_, ok := x.(context.Context)
|
||||
|
||||
return ok
|
||||
}
|
||||
|
||||
func (cm *anyMatcher) String() string {
|
||||
return "is a context.Context"
|
||||
}
|
||||
Reference in New Issue
Block a user