-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patherrors_test.go
More file actions
31 lines (28 loc) · 720 Bytes
/
errors_test.go
File metadata and controls
31 lines (28 loc) · 720 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
31
package fixer
import (
"net/http"
"testing"
)
func TestNewError(t *testing.T) {
for _, msg := range []string{"", "foo", "bar"} {
if got := NewError(msg).Error(); got != msg {
t.Fatalf("NewError(%q).Error() = %q, want %q", msg, got, msg)
}
}
}
func TestResponseError(t *testing.T) {
for _, tt := range []struct {
resp *http.Response
want error
}{
{nil, ErrNilResponse},
{&http.Response{}, ErrUnexpectedStatus},
{&http.Response{StatusCode: 200}, nil},
{&http.Response{StatusCode: 404}, ErrNotFound},
{&http.Response{StatusCode: 422}, ErrUnprocessableEntity},
} {
if got := responseError(tt.resp); got != tt.want {
t.Fatalf("responseError(tt.resp) = %v, want %v", got, tt.want)
}
}
}