Skip to content

Commit 47a4a99

Browse files
add ErrIntentional
1 parent 16b81d4 commit 47a4a99

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

testr.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77
"reflect"
88
)
99

10+
// ErrIntentional is a sentinel error represents intentional error in the test.
11+
var ErrIntentional = errors.New("testr: intentional error")
12+
1013
// T represents testing.T.
1114
type T interface {
1215
Helper()

testr_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package testr_test
22

33
import (
4-
"errors"
54
"testing"
65

76
"github.com/smoothprogrammer/testr"
@@ -354,11 +353,11 @@ func TestNilT(t *testing.T) {
354353
func TestMust(t *testing.T) {
355354
assert := testr.New(t)
356355
testr.Must(nil)
357-
assert.Panic(func() { testr.Must(errors.New("intentional error")) })
356+
assert.Panic(func() { testr.Must(testr.ErrIntentional) })
358357
}
359358

360359
func TestMustV(t *testing.T) {
361360
assert := testr.New(t)
362361
assert.Equal(testr.MustV("ok", nil), "ok")
363-
assert.Panic(func() { testr.MustV("panic", errors.New("intentional error")) })
362+
assert.Panic(func() { testr.MustV("panic", testr.ErrIntentional) })
364363
}

0 commit comments

Comments
 (0)