MCPcopy Create free account
hub / github.com/stretchr/testify / NotErrorIs

Function NotErrorIs

assert/assertions.go:2115–2134  ·  view source on GitHub ↗

NotErrorIs asserts that none of the errors in err's chain matches target. This is a wrapper for errors.Is.

(t TestingT, err, target error, msgAndArgs ...interface{})

Source from the content-addressed store, hash-verified

2113// NotErrorIs asserts that none of the errors in err's chain matches target.
2114// This is a wrapper for errors.Is.
2115func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
2116 if h, ok := t.(tHelper); ok {
2117 h.Helper()
2118 }
2119 if !errors.Is(err, target) {
2120 return true
2121 }
2122
2123 var expectedText string
2124 if target != nil {
2125 expectedText = target.Error()
2126 }
2127
2128 chain := buildErrorChainString(err)
2129
2130 return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+
2131 "found: %q\n"+
2132 "in chain: %s", expectedText, chain,
2133 ), msgAndArgs...)
2134}
2135
2136// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
2137// This is a wrapper for errors.As.

Callers 4

NotErrorIsFunction · 0.92
NotErrorIsfFunction · 0.70
TestNotErrorIsFunction · 0.70
NotErrorIsMethod · 0.70

Calls 5

buildErrorChainStringFunction · 0.85
IsMethod · 0.80
FailFunction · 0.70
HelperMethod · 0.65
ErrorMethod · 0.45

Tested by 1

TestNotErrorIsFunction · 0.56