-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
52 lines (43 loc) · 1.34 KB
/
errors_test.go
File metadata and controls
52 lines (43 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package assert
import (
"errors"
"testing"
)
func TestIsError(t *testing.T) {
a := New(t)
mockA := New(new(testing.T))
err1 := errors.New("error 1")
err2 := errors.New("error 2")
err3 := errors.New("error 3")
testIsError(a, mockA, errors.New("test"), err1, false)
testIsError(a, mockA, err1, err1, true)
testIsError(a, mockA, err1, err2, false)
testIsError(a, mockA, err1, err3, false)
}
func testIsError(a, mockA *Assertion, err, target error, isError bool) {
a.T.Helper()
testAssertionFunction(a, "IsError", func() error {
return IsError(mockA.T, err, target)
}, isError)
testAssertionFunction(a, "Assertion.IsError", func() error {
return mockA.IsError(err, target)
}, isError)
testAssertionFunction(a, "NotIsError", func() error {
return NotIsError(mockA.T, err, target)
}, !isError)
testAssertionFunction(a, "Assertion.NotIsError", func() error {
return mockA.NotIsError(err, target)
}, !isError)
testAssertionNowFunction(a, "IsErrorNow", func() {
IsErrorNow(mockA.T, err, target)
}, !isError)
testAssertionNowFunction(a, "Assertion.IsErrorNow", func() {
mockA.IsErrorNow(err, target)
}, !isError)
testAssertionNowFunction(a, "NotIsErrorNow", func() {
NotIsErrorNow(mockA.T, err, target)
}, isError)
testAssertionNowFunction(a, "Assertion.NotIsErrorNow", func() {
mockA.NotIsErrorNow(err, target)
}, isError)
}