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

Function TestErrorIs

assert/assertions_test.go:3213–3281  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

3211}
3212
3213func TestErrorIs(t *testing.T) {
3214 tests := []struct {
3215 err error
3216 target error
3217 result bool
3218 resultErrMsg string
3219 }{
3220 {
3221 err: io.EOF,
3222 target: io.EOF,
3223 result: true,
3224 },
3225 {
3226 err: fmt.Errorf("wrap: %w", io.EOF),
3227 target: io.EOF,
3228 result: true,
3229 },
3230 {
3231 err: io.EOF,
3232 target: io.ErrClosedPipe,
3233 result: false,
3234 resultErrMsg: "" +
3235 "Target error should be in err chain:\n" +
3236 "expected: \"io: read/write on closed pipe\"\n" +
3237 "in chain: \"EOF\"\n",
3238 },
3239 {
3240 err: nil,
3241 target: io.EOF,
3242 result: false,
3243 resultErrMsg: "" +
3244 "Target error should be in err chain:\n" +
3245 "expected: \"EOF\"\n" +
3246 "in chain: \n",
3247 },
3248 {
3249 err: io.EOF,
3250 target: nil,
3251 result: false,
3252 resultErrMsg: "" +
3253 "Target error should be in err chain:\n" +
3254 "expected: \"\"\n" +
3255 "in chain: \"EOF\"\n",
3256 },
3257 {
3258 err: nil,
3259 target: nil,
3260 result: true,
3261 },
3262 {
3263 err: fmt.Errorf("abc: %w", errors.New("def")),
3264 target: io.EOF,
3265 result: false,
3266 resultErrMsg: "" +
3267 "Target error should be in err chain:\n" +
3268 "expected: \"EOF\"\n" +
3269 "in chain: \"abc: def\"\n" +
3270 "\t\"def\"\n",

Callers

nothing calls this directly

Calls 4

checkResultAndErrMsgMethod · 0.80
ErrorIsFunction · 0.70
ErrorfMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected