EqualError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error. actualObj, err := SomeFunction() require.EqualError(t, err, expectedErrorString)
(t TestingT, theError error, errString string, msgAndArgs ...interface{})
| 186 | // actualObj, err := SomeFunction() |
| 187 | // require.EqualError(t, err, expectedErrorString) |
| 188 | func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) { |
| 189 | if h, ok := t.(tHelper); ok { |
| 190 | h.Helper() |
| 191 | } |
| 192 | if assert.EqualError(t, theError, errString, msgAndArgs...) { |
| 193 | return |
| 194 | } |
| 195 | t.FailNow() |
| 196 | } |
| 197 | |
| 198 | // EqualErrorf asserts that a function returned an error (i.e. not `nil`) |
| 199 | // and that it is equal to the provided error. |