Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inaccurate MatchedBy error message #556

Closed
jsvensson opened this issue Feb 6, 2018 · 0 comments · Fixed by #557
Closed

Inaccurate MatchedBy error message #556

jsvensson opened this issue Feb 6, 2018 · 0 comments · Fixed by #557

Comments

@jsvensson
Copy link

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 pushed a commit to devslives/testify that referenced this issue Feb 11, 2018
…sest function call. closes stretchr#556

(cherry picked from commit d544d76e7e530242ef238769547e4c8fd442094e)
devdinu pushed a commit to devslives/testify that referenced this issue Feb 11, 2018
devdinu pushed a commit to devslives/testify that referenced this issue Feb 21, 2018
devdinu pushed a commit to devslives/testify that referenced this issue Feb 21, 2018
devdinu pushed a commit to devslives/testify that referenced this issue Mar 11, 2018
devdinu pushed a commit to devslives/testify that referenced this issue Mar 11, 2018
ernesto-jimenez pushed a commit that referenced this issue Mar 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant