-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Incorrect require.Error() docs #1609
Comments
hello @andig is this the |
Thank you for the quick reply. Seems I was actually looking at // Error asserts that a function returned an error (i.e. not `nil`).
//
// actualObj, err := SomeFunction()
// if assert.Error(t, err) {
// assert.Equal(t, expectedError, err)
// }
func Error(t TestingT, err error, msgAndArgs ...interface{}) {
if h, ok := t.(tHelper); ok {
h.Helper()
}
if assert.Error(t, err, msgAndArgs...) {
return
}
t.FailNow()
} |
yea I think so, but I checked the docs for |
The doc-string for Error needs to be made into one which works for both the assert and require packages. Especially after #1610 is merged. I'd suggest simply removing the if statement and the Equal call from the example. Especially since EqualError exists. |
Description
The error docs read:
This indicates that
Error()
has abool
return value which it hasn't. There is no way to checkexpectedError
like this.Expected behavior
Error docs should show actual usage. It would be nice if
Error()
actually allowed for checking the specific error value.The text was updated successfully, but these errors were encountered: