-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors_test.go
More file actions
40 lines (34 loc) · 978 Bytes
/
Copy patherrors_test.go
File metadata and controls
40 lines (34 loc) · 978 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
32
33
34
35
36
37
38
39
40
package espn
import (
"errors"
"testing"
)
func TestAPIError_Error(t *testing.T) {
e := &APIError{Code: 404, Message: "not found"}
if got := e.Error(); got != "espn: API error 404: not found" {
t.Fatalf("Error() = %q, want \"espn: API error 404: not found\"", got)
}
}
func TestAPIError_Is_notFound(t *testing.T) {
e := &APIError{Code: 404, Message: "not found"}
if !errors.Is(e, ErrNotFound) {
t.Fatal("expected errors.Is(APIError{404}, ErrNotFound) = true")
}
}
func TestAPIError_Is_other(t *testing.T) {
e := &APIError{Code: 500, Message: "server error"}
if errors.Is(e, ErrNotFound) {
t.Fatal("expected errors.Is(APIError{500}, ErrNotFound) = false")
}
}
func TestAPIError_Is_zeroCopde(t *testing.T) {
e := &APIError{Code: 0, Message: ""}
if errors.Is(e, ErrNotFound) {
t.Fatal("expected errors.Is(APIError{0}, ErrNotFound) = false")
}
}
func TestErrNotFound_isNotNil(t *testing.T) {
if ErrNotFound == nil {
t.Fatal("ErrNotFound is nil")
}
}