-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy patherror_test.go
56 lines (48 loc) · 1.47 KB
/
error_test.go
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
53
54
55
56
package wmenu
import (
"errors"
"testing"
"github.com/stretchr/testify/assert"
)
var (
testInvalid = newMenuError(ErrInvalid, "1", 0)
testDuplicate = newMenuError(ErrDuplicate, "2", 0)
testTooMany = newMenuError(ErrTooMany, "", 0)
testNoResponse = newMenuError(ErrNoResponse, "", 0)
errNormal = errors.New("Opps")
errMenu = newMenuError(errors.New("General"), "", 0)
)
func TestIsInvalidErr(t *testing.T) {
assert := assert.New(t)
assert.True(IsInvalidErr(testInvalid))
assert.False(IsInvalidErr(testDuplicate))
assert.False(IsInvalidErr(errNormal))
}
func TestIsDuplicateErr(t *testing.T) {
assert := assert.New(t)
assert.True(IsDuplicateErr(testDuplicate))
assert.False(IsDuplicateErr(testInvalid))
assert.False(IsDuplicateErr(errNormal))
}
func TestIsTooManyErr(t *testing.T) {
assert := assert.New(t)
assert.True(IsTooManyErr(testTooMany))
assert.False(IsTooManyErr(testDuplicate))
assert.False(IsTooManyErr(errNormal))
}
func TestIsNoResponseErr(t *testing.T) {
assert := assert.New(t)
assert.True(IsNoResponseErr(testNoResponse))
assert.False(IsNoResponseErr(testDuplicate))
assert.False(IsNoResponseErr(errNormal))
}
func TestIsMenuError(t *testing.T) {
assert := assert.New(t)
assert.True(IsMenuErr(testNoResponse))
assert.True(IsMenuErr(testDuplicate))
assert.True(IsMenuErr(testInvalid))
assert.True(IsMenuErr(testTooMany))
assert.True(IsMenuErr(testNoResponse))
assert.True(IsMenuErr(errMenu))
assert.False(IsMenuErr(errNormal))
}