ErrorContains asserts that a function returned an error (i.e. not `nil`) and that the error contains the specified substring. actualObj, err := SomeFunction() require.ErrorContains(t, err, expectedErrorSubString)
(t TestingT, theError error, contains string, msgAndArgs ...interface{})
| 339 | // actualObj, err := SomeFunction() |
| 340 | // require.ErrorContains(t, err, expectedErrorSubString) |
| 341 | func ErrorContains(t TestingT, theError error, contains string, msgAndArgs ...interface{}) { |
| 342 | if h, ok := t.(tHelper); ok { |
| 343 | h.Helper() |
| 344 | } |
| 345 | if assert.ErrorContains(t, theError, contains, msgAndArgs...) { |
| 346 | return |
| 347 | } |
| 348 | t.FailNow() |
| 349 | } |
| 350 | |
| 351 | // ErrorContainsf asserts that a function returned an error (i.e. not `nil`) |
| 352 | // and that the error contains the specified substring. |