forked from cloudflare/cloudflare-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
52 lines (47 loc) · 1.01 KB
/
errors_test.go
File metadata and controls
52 lines (47 loc) · 1.01 KB
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
package cloudflare
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestError_Error(t *testing.T) {
tests := map[string]struct {
response []ResponseInfo
want string
}{
"basic complete response": {
response: []ResponseInfo{{
Code: 10000,
Message: "Authentication error",
}},
want: "Authentication error (10000)",
},
"multiple complete response": {
response: []ResponseInfo{
{
Code: 10000,
Message: "Authentication error",
},
{
Code: 10001,
Message: "Not authentication error",
},
},
want: "Authentication error (10000), Not authentication error (10001)",
},
"missing internal error code": {
response: []ResponseInfo{{
Message: "something is broke",
}},
want: "something is broke",
},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
got := &RequestError{cloudflareError: &Error{
StatusCode: 400,
Errors: tc.response,
}}
assert.Equal(t, tc.want, got.Error())
})
}
}