-
Notifications
You must be signed in to change notification settings - Fork 1
/
errors_test.go
60 lines (52 loc) · 932 Bytes
/
errors_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
package gonfig
import (
"errors"
"reflect"
"testing"
"github.com/stretchr/testify/assert"
)
func TestInvalidInputError_Error(t *testing.T) {
var i interface{}
var s struct{}
var sp *struct{}
num := 2
tests := []struct {
input interface{}
expected string
}{
{
input: nil,
expected: "<nil>",
},
{
input: i,
expected: "<nil>",
},
{
input: s,
expected: "non-pointer type",
},
{
input: sp,
expected: "nil pointer",
},
{
input: &num,
expected: "non-struct type",
},
}
for _, tc := range tests {
ie := InvalidInputError{
Value: reflect.ValueOf(tc.input),
}
assert.EqualError(t, &ie, "gonfig: invalid input: "+tc.expected)
}
}
func TestConfigErrors_Error(t *testing.T) {
ce := ConfigErrors{
errors.New("first"),
errors.New("second"),
errors.New("third"),
}
assert.EqualError(t, ce, "gonfig:\n * first\n * second\n * third")
}