-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
This might sorta-maybe be related to #432.
I'm trying to use MatchedBy to verify that I get the proper object. When I have MatchedBy just return true tests work:
s.foo.On("UpdateFoo", mock.MatchedBy(func(foo *model.Foo) bool {
return true
})).Return(nil)
However, as soon as I'm actually trying to compare values on foo like this:
s.foo.On("UpdateFoo", mock.MatchedBy(func(foo *model.Foo) bool {
// LastSeen is a time.Time
return foo.LastSeen.Equal(timer.Timestamp())
})).Return(nil)
Then I get this panic:
UpdateFoo(*model.Foo)
0: &model.Foo{ /* stuff */}
The closest call I have is:
UpdateFoo(mock.argumentMatcher)
0: mock.argumentMatcher{fn:reflect.Value{typ:(*reflect.rtype)(0x769b00), ptr:(unsafe.Pointer)(0x8036c0), flag:0x13}}
Update: After plenty of staring at my test cases and spotting that my test values didn't line up with what I wanted to match it against, I isolated this to Testify returning that error as soon as MatchedBy can't match the object we're testing. Simply having MatchedBy return false will give the same error.
That error message should be changed to give some information about what caused it, in this case MatchedBy() failing to match.
devdinu
Metadata
Metadata
Assignees
Labels
No labels