-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
30 lines (27 loc) · 796 Bytes
/
Copy patherrors_test.go
File metadata and controls
30 lines (27 loc) · 796 Bytes
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
package bitget
import "testing"
func TestErrorAndMapErrorCode(t *testing.T) {
err := &Error{Code: "40001", Message: "invalid API key"}
if got, want := err.Error(), "bitget: api error: code=40001, message=invalid API key"; got != want {
t.Errorf("Error() = %q, want %q", got, want)
}
tests := map[string]error{
"": nil,
"00000": nil,
"40001": ErrUnauthorized,
"40002": ErrInvalidSignature,
"40004": ErrInvalidTimestamp,
"40012": ErrPermissionDenied,
"429": ErrRateLimited,
"40018": ErrInvalidParameter,
"43012": ErrInsufficientFunds,
"43025": ErrOrderNotFound,
"50000": ErrInternalServer,
"other": nil,
}
for code, want := range tests {
if got := MapErrorCode(code); got != want {
t.Errorf("MapErrorCode(%q) = %v, want %v", code, got, want)
}
}
}