| 1 |
// Package check_test tests check with external dependencies |
| 2 |
// that must stay out of the core go.mod. |
| 3 |
// |
| 4 |
// This module uses `replace github.com/powerman/check => ../` |
| 5 |
// and is NEVER tagged or released. |
| 6 |
package check_test |
| 7 |
|
| 8 |
import ( |
| 9 |
"io" |
| 10 |
"testing" |
| 11 |
|
| 12 |
"github.com/pkg/errors" |
| 13 |
|
| 14 |
"github.com/powerman/check" |
| 15 |
) |
| 16 |
|
| 17 |
func TestErrPkgErrors(tt *testing.T) { |
| 18 |
t := check.T(tt) |
| 19 |
|
| 20 |
// pkg/errors.Wrap with io.EOF. |
| 21 |
t.Err(errors.Wrap(io.EOF, "wrapped"), io.EOF) |
| 22 |
t.NotErr(errors.Wrap(io.EOF, "wrapped"), io.ErrUnexpectedEOF) |
| 23 |
|
| 24 |
// Double wrapped. |
| 25 |
t.Err(errors.Wrap(errors.Wrap(io.EOF, "outer"), "inner"), io.EOF) |
| 26 |
t.NotErr(errors.Wrap(errors.Wrap(io.EOF, "outer"), "inner"), io.ErrUnexpectedEOF) |
| 27 |
|
| 28 |
// pkg/errors.Wrap with nil returns nil. |
| 29 |
t.Err(nil, nil) |
| 30 |
} |
| 31 |
|
| 32 |
func TestNonPkgErrors(tt *testing.T) { |
| 33 |
t := check.T(tt) |
| 34 |
|
| 35 |
// Non-pkg/errors errors still work. |
| 36 |
t.Err(io.EOF, io.EOF) |
| 37 |
t.NotErr(io.EOF, io.ErrUnexpectedEOF) |
| 38 |
} |