| 42 | } |
| 43 | |
| 44 | func TestSentinelWithMultipleWrappedErrors(t *testing.T) { |
| 45 | t.Parallel() |
| 46 | myNetError := &net.OpError{} |
| 47 | myAddrError := &net.AddrError{} |
| 48 | |
| 49 | error := Wrap(ErrOutOfBrokers, myNetError, myAddrError) |
| 50 | |
| 51 | if !errors.Is(error, ErrOutOfBrokers) { |
| 52 | t.Error("errors.Is unexpected result") |
| 53 | } |
| 54 | |
| 55 | if !errors.Is(error, myNetError) { |
| 56 | t.Error("errors.Is unexpected result") |
| 57 | } |
| 58 | |
| 59 | if !errors.Is(error, myAddrError) { |
| 60 | t.Error("errors.Is unexpected result") |
| 61 | } |
| 62 | |
| 63 | unwrapped := errors.Unwrap(error) |
| 64 | if errors.Is(unwrapped, ErrOutOfBrokers) || !errors.Is(unwrapped, myNetError) || !errors.Is(unwrapped, myAddrError) { |
| 65 | t.Errorf("unwrapped value unexpected result") |
| 66 | } |
| 67 | } |