-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror_test.go
58 lines (54 loc) · 1.02 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
package vaddie
import (
"errors"
"testing"
)
func Test_JoinAndWithError(t *testing.T) {
a := errors.New("a")
if JoinAnd(nil, a, nil) != a {
t.Fail()
}
}
func Test_JoinAndNoError(t *testing.T) {
if JoinAnd(nil, nil) != nil {
t.Fail()
}
}
func Test_ValidationError_Message(t *testing.T) {
for _, tc := range []struct {
err error
msg string
}{
{
err: &ValidationError{
Key: "value",
Message: "did not pass",
Help: "",
Index: nil,
},
msg: "value did not pass",
},
{
err: &ValidationError{
Key: "anotherThing",
Message: "is not the best",
Help: "try using a hammer",
Index: nil,
},
msg: "anotherThing is not the best ( try using a hammer )",
},
{
err: &ValidationError{
Key: "whichThing",
Message: "should be fixed",
Help: "keep it in check",
Index: toPtr(5),
},
msg: "whichThing[5] should be fixed ( keep it in check )",
},
} {
if tc.err.Error() != tc.msg {
t.Errorf("%v != %v", tc.err.Error(), tc.msg)
}
}
}