MCPcopy
hub / github.com/expr-lang/expr / EqualError

Function EqualError

internal/testify/assert/assertions.go:1577–1593  ·  view source on GitHub ↗

EqualError asserts that a function returned an error (i.e. not `nil`) and that it is equal to the provided error. actualObj, err := SomeFunction() assert.EqualError(t, err, expectedErrorString)

(t TestingT, theError error, errString string, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

1575// actualObj, err := SomeFunction()
1576// assert.EqualError(t, err, expectedErrorString)
1577func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool {
1578 if h, ok := t.(tHelper); ok {
1579 h.Helper()
1580 }
1581 if !Error(t, theError, msgAndArgs...) {
1582 return false
1583 }
1584 expected := errString
1585 actual := theError.Error()
1586 // don't need to use deep equals here, we know they are both strings
1587 if expected != actual {
1588 return Fail(t, fmt.Sprintf("Error message not equal:\n"+
1589 "expected: %q\n"+
1590 "actual : %q", expected, actual), msgAndArgs...)
1591 }
1592 return true
1593}
1594
1595// ErrorContains asserts that a function returned an error (i.e. not `nil`)
1596// and that the error contains the specified substring.

Callers 4

EqualErrorFunction · 0.92
EqualErrorfFunction · 0.70
TestEqualErrorFunction · 0.70
EqualErrorMethod · 0.70

Calls 5

SprintfMethod · 0.80
ErrorFunction · 0.70
FailFunction · 0.70
HelperMethod · 0.45
ErrorMethod · 0.45

Tested by 1

TestEqualErrorFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…