MCPcopy
hub / github.com/stretchr/testify / ErrorContains

Function ErrorContains

require/require.go:341–349  ·  view source on GitHub ↗

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{})

Source from the content-addressed store, hash-verified

339// actualObj, err := SomeFunction()
340// require.ErrorContains(t, err, expectedErrorSubString)
341func 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.

Callers 2

ErrorContainsMethod · 0.70
TestErrorContainsFunction · 0.70

Calls 3

ErrorContainsFunction · 0.92
HelperMethod · 0.65
FailNowMethod · 0.65

Tested by 1

TestErrorContainsFunction · 0.56