refactor: improve code structure and add tests

This commit is contained in:
2022-02-15 01:07:05 +00:00
parent e844b45865
commit f5cfcf86af
6 changed files with 822 additions and 71 deletions

26
any.go Normal file
View 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"
}