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

Function TestErrorIs

assert/assertions_test.go:3697–3764  ·  assert/assertions_test.go::TestErrorIs
(t *testing.T)

Source from the content-addressed store, hash-verified

3695}
3696
3697func TestErrorIs(t *testing.T) {
3698 t.Parallel()
3699
3700 tests := []struct {
3701 err error
3702 target error
3703 result bool
3704 resultErrMsg string
3705 }{
3706 {
3707 err: io.EOF,
3708 target: io.EOF,
3709 result: true,
3710 },
3711 {
3712 err: fmt.Errorf("wrap: %w", io.EOF),
3713 target: io.EOF,
3714 result: true,
3715 },
3716 {
3717 err: io.EOF,
3718 target: io.ErrClosedPipe,
3719 result: false,
3720 resultErrMsg: "" +
3721 "Target error should be in err chain:\n" +
3722 "expected: \"io: read/write on closed pipe\"\n" +
3723 "in chain: \"EOF\"\n",
3724 },
3725 {
3726 err: nil,
3727 target: io.EOF,
3728 result: false,
3729 resultErrMsg: "Expected error with \"EOF\" in chain but got nil.\n",
3730 },
3731 {
3732 err: io.EOF,
3733 target: nil,
3734 result: false,
3735 resultErrMsg: "" +
3736 "Target error should be in err chain:\n" +
3737 "expected: \"\"\n" +
3738 "in chain: \"EOF\"\n",
3739 },
3740 {
3741 err: nil,
3742 target: nil,
3743 result: true,
3744 },
3745 {
3746 err: fmt.Errorf("abc: %w", errors.New("def")),
3747 target: io.EOF,
3748 result: false,
3749 resultErrMsg: "" +
3750 "Target error should be in err chain:\n" +
3751 "expected: \"EOF\"\n" +
3752 "in chain: \"abc: def\"\n" +
3753 "\t\"def\"\n",
3754 },

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected