-
Notifications
You must be signed in to change notification settings - Fork 0
/
errors_test.go
79 lines (71 loc) · 2.14 KB
/
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package climacell
import (
"fmt"
"testing"
)
func TestHTTPError_Error(t *testing.T) {
endpoint := "/v3/weather/test"
message := "test message"
e := &HTTPError{
Endpoint: endpoint,
Message: message,
}
want := fmt.Sprintf("error %v: %v", endpoint, message)
if got := e.Error(); got != want {
t.Errorf("Error() = %v, want %v", got, want)
}
}
func TestBadRequestError_Error(t *testing.T) {
endpoint := "/v3/weather/test"
message := "test message"
e := newBadRequestError(endpoint, message)
want := fmt.Sprintf("bad request %v: %v", endpoint, message)
if got := e.Error(); got != want {
t.Errorf("Error() = %v, want %v", got, want)
}
}
func TestForbiddenError_Error(t *testing.T) {
endpoint := "/v3/weather/test"
message := "test message"
e := newForbiddenError(endpoint, message)
want := fmt.Sprintf("forbidden %v: %v", endpoint, message)
if got := e.Error(); got != want {
t.Errorf("Error() = %v, want %v", got, want)
}
}
func TestInternalServerError_Error(t *testing.T) {
endpoint := "/v3/weather/test"
message := "test message"
e := newInternalServerError(endpoint, message)
want := fmt.Sprintf("internal server error %v: %v", endpoint, message)
if got := e.Error(); got != want {
t.Errorf("Error() = %v, want %v", got, want)
}
}
func TestTooManyRequestError_Error(t *testing.T) {
endpoint := "/v3/weather/test"
message := "test message"
e := newTooManyRequestError(endpoint, message)
want := fmt.Sprintf("too many requests %v: %v", endpoint, message)
if got := e.Error(); got != want {
t.Errorf("Error() = %v, want %v", got, want)
}
}
func TestUnauthorizedError_Error(t *testing.T) {
endpoint := "/v3/weather/test"
message := "test message"
e := newUnauthorizedError(endpoint, message)
want := fmt.Sprintf("unauthorized %v: %v", endpoint, message)
if got := e.Error(); got != want {
t.Errorf("Error() = %v, want %v", got, want)
}
}
func TestNotFoundError_Error(t *testing.T) {
endpoint := "/v3/weather/test"
message := "test message"
e := newNotFoundError(endpoint, message)
want := fmt.Sprintf("not found error %v: %v", endpoint, message)
if got := e.Error(); got != want {
t.Errorf("Error() = %v, want %v", got, want)
}
}