-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_test.go
44 lines (40 loc) · 912 Bytes
/
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
package zconfig
import (
"github.com/stretchr/testify/require"
"github.com/zonewave/pkgs/standutil/fileutil"
"testing"
)
func TestErrorString(t *testing.T) {
tests := []struct {
name string
err error
want string
}{
// TODO: Add test cases.
{
name: "file not found",
err: NewErrFileNotFound("test", "", fileutil.ErrNotFound),
want: "test",
},
{
name: "unsupported config type",
err: NewErrUnsupportedCfgType("test"),
want: "Unsupported cfg type:string,should be pointer to struct",
},
{
name: "invalid config ext",
err: NewErrInvalidCfgExt("test"),
want: "Unsupported Config file ext \"test\"",
},
{
name: "unsupported unmarshal",
err: NewErrUnsupportedUnmarshal("test"),
want: "Unsupported Unmarshal \"test\"",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
require.ErrorContains(t, tt.err, tt.want)
})
}
}