-
Notifications
You must be signed in to change notification settings - Fork 123
/
Copy patherror_test.go
99 lines (76 loc) · 1.78 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// REVU - whitebox testing of internal comps -- OK.
package redis
/*
import (
"log"
"testing"
)
type simpleError struct {
}
func (e simpleError) Error() string {
return "a simple error"
}
type tspec_et struct {
msg string
category ErrorCategory
cause error
}
func testspec_et() tspec_et {
var spec tspec_et
spec.msg = "this is a test error message"
// spec.category = SYSTEM_ERR
return spec
}
func commonErrorTest(t *testing.T, e Error, category ErrorCategory) {
if e.Error() == "" {
t.Error("BUG: nil results for e.Error()")
}
if e.Message() == "" {
t.Error("BUG: nil results for e.Message()")
}
if e.Category() != category {
t.Errorf("BUG: category not set correctly (exp:%s | got:%s)", category, e.Category())
}
}
func TestNewError(t *testing.T) {
spec := testspec_et()
e := NewError(spec.category, spec.msg)
commonErrorTest(t, e, spec.category)
}
func TestPrivateNewRedisError(t *testing.T) {
spec := testspec_et()
e := _newRedisError(spec.category, spec.msg)
commonErrorTest(t, e, spec.category)
}
func TestNewRedisError(t *testing.T) {
spec := testspec_et()
e := NewRedisError(spec.msg)
commonErrorTest(t, e, REDIS_ERR)
if !e.IsRedisError() {
t.Error("BUG: IsRedisError")
}
}
func TestNewSystemError(t *testing.T) {
spec := testspec_et()
e := NewSystemError(spec.msg)
commonErrorTest(t, e, SYSTEM_ERR)
if e.IsRedisError() {
t.Error("BUG: IsRedisError")
}
}
func TestNewErrorWithCause(t *testing.T) {
spec := testspec_et()
var cause simpleError
e := NewErrorWithCause(spec.category, spec.msg, cause)
commonErrorTest(t, e, spec.category)
if e.Cause() == nil {
t.Error("BUG: cause is nil")
}
if e.Cause() != cause {
t.Error("BUG: cause not set correctly")
}
}
func TestEnd_et(t *testing.T) {
log.Println("-- error test completed")
}
*/