8 "github.com/bytom/vapor/errors"
12 errNotFound = errors.New("not found")
13 testFormatter = Formatter{
14 Default: Info{500, "CH000", "Internal server error"},
15 IsTemporary: func(Info, error) bool { return false },
16 Errors: map[error]Info{
17 errNotFound: {400, "CH002", "Not found"},
22 // Dummy error type, to test that Format
23 // doesn't panic when it's used as a map key.
26 func (err sliceError) Error() string { return "slice error" }
28 func TestInfo(t *testing.T) {
34 {context.Canceled, 500},
36 {errors.Wrap(errNotFound, "foo"), 400},
38 {fmt.Errorf("an error!"), 500},
41 for _, test := range cases {
42 resp := testFormatter.Format(test.err)
43 got := resp.HTTPStatus
45 t.Errorf("errInfo(%#v) = %d want %d", test.err, got, test.want)