forked from cyruzin/golang-tmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tv_seasons_test.go
122 lines (104 loc) · 3.95 KB
/
tv_seasons_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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package tmdb
func (suite *TMBDTestSuite) TestGetTVSeasonDetails() {
got, err := suite.client.GetTVSeasonDetails(gotID, 1, nil)
suite.Nil(err)
suite.Equal("Season 1", got.Name)
suite.True(got.VoteAverage > 0)
}
func (suite *TMBDTestSuite) TestGetTVSeasonDetailsFail() {
_, err := suite.client.GetTVSeasonDetails(0, 1, nil)
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}
func (suite *TMBDTestSuite) TestGetTVSeasonDetailsWithOptions() {
options := make(map[string]string)
options["language"] = "pt-BR"
got, err := suite.client.GetTVSeasonDetails(gotID, 1, options)
suite.Nil(err)
suite.Equal("1ª Temporada", got.Name)
}
func (suite *TMBDTestSuite) TestGetTVSeasonChange() {
options := make(map[string]string)
options["start_date"] = "2019-01-14"
options["end_date"] = "2019-01-25"
options["page"] = "1"
got, err := suite.client.GetTVSeasonChanges(gotSeasonID, options)
suite.Nil(err)
suite.NotNil(got.Changes[0].Items[0].ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonCredits() {
tv, err := suite.client.GetTVSeasonCredits(gotID, 7, nil)
suite.Nil(err)
suite.NotNil(tv.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonCreditsFail() {
suite.client.apiKey = ""
_, err := suite.client.GetTVSeasonCredits(0, 7, nil)
suite.Equal("code: 7 | success: false | message: Invalid API key: You must be granted a valid key.", err.Error())
}
func (suite *TMBDTestSuite) TestGetTVSeasonCreditsWithOptions() {
options := make(map[string]string)
options["language"] = "en-US"
tv, err := suite.client.GetTVSeasonCredits(gotID, 7, options)
suite.Nil(err)
suite.NotNil(tv.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonExternalIDs() {
tv, err := suite.client.GetTVSeasonExternalIDs(gotID, 7, nil)
suite.Nil(err)
suite.NotNil(tv.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonExternalIDsFail() {
suite.client.apiKey = ""
_, err := suite.client.GetTVSeasonExternalIDs(0, 7, nil)
suite.Equal("code: 7 | success: false | message: Invalid API key: You must be granted a valid key.", err.Error())
}
func (suite *TMBDTestSuite) TestGetTVSeasonExternalIDsWithOptions() {
options := make(map[string]string)
options["language"] = "en-US"
tv, err := suite.client.GetTVSeasonExternalIDs(gotID, 7, options)
suite.Nil(err)
suite.NotNil(tv.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonImages() {
tv, err := suite.client.GetTVSeasonImages(gotID, 7, nil)
suite.Nil(err)
suite.NotNil(tv.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonImagesFail() {
suite.client.apiKey = ""
_, err := suite.client.GetTVSeasonImages(0, 7, nil)
suite.Equal("code: 7 | success: false | message: Invalid API key: You must be granted a valid key.", err.Error())
}
func (suite *TMBDTestSuite) TestGetTVSeasonImagesWithOptions() {
options := make(map[string]string)
options["language"] = "en-US"
tv, err := suite.client.GetTVSeasonImages(gotID, 7, options)
suite.Nil(err)
suite.NotNil(tv.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonVideos() {
tv, err := suite.client.GetTVSeasonVideos(gotID, 7, nil)
suite.Nil(err)
suite.NotNil(tv.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonVideosFail() {
suite.client.apiKey = ""
_, err := suite.client.GetTVSeasonVideos(0, 7, nil)
suite.Equal("code: 7 | success: false | message: Invalid API key: You must be granted a valid key.", err.Error())
}
func (suite *TMBDTestSuite) TestGetTVSeasonVideosWithOptions() {
options := make(map[string]string)
options["language"] = "en-US"
tv, err := suite.client.GetTVSeasonVideos(gotID, 7, options)
suite.Nil(err)
suite.NotNil(tv.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonTranslations() {
got, err := suite.client.GetTVSeasonTranslations(gotID, 1)
suite.Nil(err)
suite.Equal(int64(gotSeasonID), got.ID)
}
func (suite *TMBDTestSuite) TestGetTVSeasonTranslationsFail() {
_, err := suite.client.GetTVSeasonTranslations(0, 1)
suite.Equal("code: 6 | success: false | message: Invalid id: The pre-requisite id is invalid or not found.", err.Error())
}