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

Function NotErrorIs

assert/assertions.go:2198–2217  ·  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

2196// NotErrorIs asserts that none of the errors in err's chain matches target.
2197// This is a wrapper for errors.Is.
2198func NotErrorIs(t TestingT, err, target error, msgAndArgs ...interface{}) bool {
2199 if h, ok := t.(tHelper); ok {
2200 h.Helper()
2201 }
2202 if !errors.Is(err, target) {
2203 return true
2204 }
2205
2206 var expectedText string
2207 if target != nil {
2208 expectedText = target.Error()
2209 }
2210
2211 chain := buildErrorChainString(err, false)
2212
2213 return Fail(t, fmt.Sprintf("Target error should not be in err chain:\n"+
2214 "found: %q\n"+
2215 "in chain: %s", expectedText, chain,
2216 ), msgAndArgs...)
2217}
2218
2219// ErrorAs asserts that at least one of the errors in err's chain matches target, and if so, sets target to that error value.
2220// 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