-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgames_test.go
More file actions
86 lines (63 loc) · 1.73 KB
/
games_test.go
File metadata and controls
86 lines (63 loc) · 1.73 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
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
80
81
82
83
84
85
86
package mlb_test
import (
"testing"
"time"
"github.com/stevepartridge/mlb"
)
const (
validDate1 = "2017/05/17"
invalidDate1 = "00/01/01"
validTeam1 = mlb.Dodgers
)
func Test_GetGamesByDate_Success(t *testing.T) {
date, _ := time.Parse("2006/01/02", validDate1)
games, err := mlbApi.GetGamesByDate(date)
if err != nil {
t.Error("Should not error: " + err.Error())
}
if len(games) == 0 {
t.Error("Games should be more than zero.")
}
}
func Test_GetGamesByDate_Failure(t *testing.T) {
date, _ := time.Parse("2006/01/02", invalidDate1)
games, err := mlbApi.GetGamesByDate(date)
if err == nil {
t.Error("Should be an error")
}
if len(games) > 0 {
t.Error("Games should not be more than zero.")
}
}
func Test_GetGamesByDateRange_Failure_InvalidEndDate(t *testing.T) {
start, _ := time.Parse("2006/01/02", validDate1)
end, _ := time.Parse("2006/01/02", invalidDate1)
games, err := mlbApi.GetGamesByDateRange(start, end)
if err == nil {
t.Error("Should be an error")
}
if len(games) > 0 {
t.Error("Games should not be more than zero.")
}
}
func Test_GetGamesByDateForTeam_Success(t *testing.T) {
date, _ := time.Parse("2006/01/02", validDate1)
games, err := mlbApi.GetGamesByDateForTeam(date, validTeam1)
if err != nil {
t.Error("Should not error: " + err.Error())
}
if len(games) == 0 {
t.Error("Games should be more than zero.")
}
}
func Test_GetGamesByDateRangeForTeam_Success(t *testing.T) {
start, _ := time.Parse("2006/01/02", validDate1)
end, _ := time.Parse("2006/01/02", validDate1)
games, err := mlbApi.GetGamesByDateRangeForTeam(start, end, validTeam1)
if err != nil {
t.Error("Should not error: " + err.Error())
}
if len(games) == 0 {
t.Error("Games should be more than zero.")
}
}