Open cadina opened 3 years ago
now i'm using a simple wrapper like:
type GomegaMatcher interface {
Match(actual interface{}) (success bool, err error)
FailureMessage(actual interface{}) (message string)
}
type matcher struct {
GomegaMatcher
x interface{}
}
func (m matcher) Matches(x interface{}) bool {
m.x = x
result, _ := m.Match(x)
return result
}
func (m matcher) String() string {
return m.FailureMessage(m.x)
}
func m(gmather GomegaMatcher) gomock.Matcher {
return matcher{gmather, nil}
}
I was going to ask if a wrapper was working. That would be what I would recommend and how I would approach it.
I could see adding a gomock adapter extension to gomega (something like gomega/extensions/gomockadaptor
) - but i'd prefer not making this part of the core DSL or gomega matcher interface.
I was going to ask if a wrapper was working. That would be what I would recommend and how I would approach it.
I could see adding a gomock adapter extension to gomega (something like
gomega/extensions/gomockadaptor
) - but i'd prefer not making this part of the core DSL or gomega matcher interface.
that would be perfect.
i'm also thinking about taking full advantage of mockgen or something like that. just like how it generates mock recorders, we should be able to extract struct types from input and output arguments and generate strong typed structure matchers. that will be a lot better than the map we used for MatchAllFields
.
i'm heads down working on ginkgo 2.0 these days but making it easier to build custom marchers in gomega is something i'm interested in working on next. if you have bandwidth and are up for a PR I'd be happy to to pull in a gomock adapter and to take a look at a matcher generator with you!
@onsi sure. i will take some time to walk through the codebase and see what i can do.
so we can use them as gomock EXPECT arguments. the original matchers of gomock is too weak when dealing with complex types and assertions.