Skip to content

Commit 2070f69

Browse files
authored
Improved testing (#85)
1 parent 7f32997 commit 2070f69

File tree

16 files changed

+104
-54
lines changed

16 files changed

+104
-54
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010

1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
13+
14+
.DS_Store

account_test.go

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package tmdb
22

33
func (suite *TMBDTestSuite) TestGetAccountDetails() {
4-
suite.client.SetSessionID(sessionID)
4+
err := suite.client.SetSessionID(sessionID)
5+
suite.Nil(err)
56
response, err := suite.client.GetAccountDetails()
67
suite.Nil(err)
78
suite.NotNil(response.ID)
@@ -14,14 +15,16 @@ func (suite *TMBDTestSuite) TestGetAccountDetailsFail() {
1415
}
1516

1617
func (suite *TMBDTestSuite) TestAccountCreatedLists() {
17-
suite.client.SetSessionID(sessionID)
18+
err := suite.client.SetSessionID(sessionID)
19+
suite.Nil(err)
1820
response, err := suite.client.GetCreatedLists(0, nil)
1921
suite.Nil(err)
2022
suite.NotNil(response.Page)
2123
}
2224

2325
func (suite *TMBDTestSuite) TestAccountCreatedListsWithOptions() {
24-
suite.client.SetSessionID(sessionID)
26+
err := suite.client.SetSessionID(sessionID)
27+
suite.Nil(err)
2528
options := make(map[string]string)
2629
options["language"] = "pt-BR"
2730
options["page"] = "1"
@@ -37,14 +40,16 @@ func (suite *TMBDTestSuite) TestAccountCreatedListsFail() {
3740
}
3841

3942
func (suite *TMBDTestSuite) TestAccountFavoriteMovies() {
40-
suite.client.SetSessionID(sessionID)
43+
err := suite.client.SetSessionID(sessionID)
44+
suite.Nil(err)
4145
response, err := suite.client.GetFavoriteMovies(0, nil)
4246
suite.Nil(err)
4347
suite.NotNil(response.Page)
4448
}
4549

4650
func (suite *TMBDTestSuite) TestAccountFavoriteMoviesWithOptions() {
47-
suite.client.SetSessionID(sessionID)
51+
err := suite.client.SetSessionID(sessionID)
52+
suite.Nil(err)
4853
options := make(map[string]string)
4954
options["language"] = "pt-BR"
5055
options["page"] = "1"
@@ -60,14 +65,16 @@ func (suite *TMBDTestSuite) TestAccountFavoriteMovieFail() {
6065
}
6166

6267
func (suite *TMBDTestSuite) TestAccountFavoriteTVShows() {
63-
suite.client.SetSessionID(sessionID)
68+
err := suite.client.SetSessionID(sessionID)
69+
suite.Nil(err)
6470
response, err := suite.client.GetFavoriteTVShows(0, nil)
6571
suite.Nil(err)
6672
suite.NotNil(response.Page)
6773
}
6874

6975
func (suite *TMBDTestSuite) TestAccountFavoriteWithOptionsTVShows() {
70-
suite.client.SetSessionID(sessionID)
76+
err := suite.client.SetSessionID(sessionID)
77+
suite.Nil(err)
7178
options := make(map[string]string)
7279
options["language"] = "pt-BR"
7380
options["page"] = "1"
@@ -83,7 +90,8 @@ func (suite *TMBDTestSuite) TestAccountFavoriteFailTVShows() {
8390
}
8491

8592
func (suite *TMBDTestSuite) TestMarkAsFavorite() {
86-
suite.client.SetSessionID(sessionID)
93+
err := suite.client.SetSessionID(sessionID)
94+
suite.Nil(err)
8795
markAsFavorite := AccountFavorite{
8896
MediaType: "movie",
8997
MediaID: 500,
@@ -106,14 +114,16 @@ func (suite *TMBDTestSuite) TestMarkAsFavoriteFail() {
106114
}
107115

108116
func (suite *TMBDTestSuite) TestAccountRatedMovies() {
109-
suite.client.SetSessionID(sessionID)
117+
err := suite.client.SetSessionID(sessionID)
118+
suite.Nil(err)
110119
response, err := suite.client.GetRatedMovies(0, nil)
111120
suite.Nil(err)
112121
suite.NotNil(response.Page)
113122
}
114123

115124
func (suite *TMBDTestSuite) TestAccountRatedMoviesWithOptions() {
116-
suite.client.SetSessionID(sessionID)
125+
err := suite.client.SetSessionID(sessionID)
126+
suite.Nil(err)
117127
options := make(map[string]string)
118128
options["language"] = "pt-BR"
119129
options["page"] = "1"
@@ -129,14 +139,16 @@ func (suite *TMBDTestSuite) TestAccountRatedMoviesFail() {
129139
}
130140

131141
func (suite *TMBDTestSuite) TestAccountRatedTVShows() {
132-
suite.client.SetSessionID(sessionID)
142+
err := suite.client.SetSessionID(sessionID)
143+
suite.Nil(err)
133144
response, err := suite.client.GetRatedTVShows(0, nil)
134145
suite.Nil(err)
135146
suite.NotNil(response.Page)
136147
}
137148

138149
func (suite *TMBDTestSuite) TestAccountRatedTVShowsWithOptions() {
139-
suite.client.SetSessionID(sessionID)
150+
err := suite.client.SetSessionID(sessionID)
151+
suite.Nil(err)
140152
options := make(map[string]string)
141153
options["language"] = "pt-BR"
142154
options["page"] = "1"
@@ -152,14 +164,16 @@ func (suite *TMBDTestSuite) TestAccountRatedTVShowsFail() {
152164
}
153165

154166
func (suite *TMBDTestSuite) TestAccountRatedTVEpisodes() {
155-
suite.client.SetSessionID(sessionID)
167+
err := suite.client.SetSessionID(sessionID)
168+
suite.Nil(err)
156169
response, err := suite.client.GetRatedTVEpisodes(0, nil)
157170
suite.Nil(err)
158171
suite.NotNil(response.Page)
159172
}
160173

161174
func (suite *TMBDTestSuite) TestAccountRatedTVEpisodesWithOptions() {
162-
suite.client.SetSessionID(sessionID)
175+
err := suite.client.SetSessionID(sessionID)
176+
suite.Nil(err)
163177
options := make(map[string]string)
164178
options["language"] = "pt-BR"
165179
options["page"] = "1"
@@ -175,14 +189,16 @@ func (suite *TMBDTestSuite) TestAccountRatedTVEpisodesFail() {
175189
}
176190

177191
func (suite *TMBDTestSuite) TestAccountMovieWatchlist() {
178-
suite.client.SetSessionID(sessionID)
192+
err := suite.client.SetSessionID(sessionID)
193+
suite.Nil(err)
179194
response, err := suite.client.GetMovieWatchlist(0, nil)
180195
suite.Nil(err)
181196
suite.NotNil(response.Page)
182197
}
183198

184199
func (suite *TMBDTestSuite) TestAccountMovieWatchlistWithOptions() {
185-
suite.client.SetSessionID(sessionID)
200+
err := suite.client.SetSessionID(sessionID)
201+
suite.Nil(err)
186202
options := make(map[string]string)
187203
options["language"] = "pt-BR"
188204
options["page"] = "1"
@@ -198,14 +214,16 @@ func (suite *TMBDTestSuite) TestAccountMovieWatchlistFail() {
198214
}
199215

200216
func (suite *TMBDTestSuite) TestAccountTVShowsWatchlist() {
201-
suite.client.SetSessionID(sessionID)
217+
err := suite.client.SetSessionID(sessionID)
218+
suite.Nil(err)
202219
response, err := suite.client.GetTVShowsWatchlist(0, nil)
203220
suite.Nil(err)
204221
suite.NotNil(response.Page)
205222
}
206223

207224
func (suite *TMBDTestSuite) TestAccountTVShowsWatchlistWithOptions() {
208-
suite.client.SetSessionID(sessionID)
225+
err := suite.client.SetSessionID(sessionID)
226+
suite.Nil(err)
209227
options := make(map[string]string)
210228
options["language"] = "pt-BR"
211229
options["page"] = "1"
@@ -221,7 +239,8 @@ func (suite *TMBDTestSuite) TestAccountTVShowsWatchlistFail() {
221239
}
222240

223241
func (suite *TMBDTestSuite) TestAddToWatchlist() {
224-
suite.client.SetSessionID(sessionID)
242+
err := suite.client.SetSessionID(sessionID)
243+
suite.Nil(err)
225244
addToWatchlist := AccountWatchlist{
226245
MediaType: "tv",
227246
MediaID: 82856,

examples/appendToResponse/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func main() {
2424
fmt.Println(err)
2525
}
2626

27-
for _, v := range movie.MovieWatchProvidersAppend.WatchProviders.Results {
27+
for _, v := range movie.WatchProviders.Results {
2828
fmt.Println(v.Flatrate)
2929
}
3030
}

examples/customHttpClient/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
}
4343

4444
// Credits - Iterate cast from append to response.
45-
for _, v := range movie.MovieCreditsAppend.Credits.Cast {
45+
for _, v := range movie.Credits.Cast {
4646
fmt.Println(v.Name)
4747
}
4848
}

examples/helpers/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func main() {
2727
fmt.Println(tmdb.GetImageURL(movie.PosterPath, tmdb.Original))
2828

2929
// Generating Video URLs
30-
for _, video := range movie.MovieVideosAppend.Videos.Results {
30+
for _, video := range movie.Videos.Results {
3131
if video.Key != "" {
3232
fmt.Println(tmdb.GetVideoURL(video.Key))
3333
}

examples/movie/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func main() {
3636
}
3737

3838
// Credits - Iterate cast from append to response.
39-
for _, v := range movie.MovieCreditsAppend.Credits.Cast {
39+
for _, v := range movie.Credits.Cast {
4040
fmt.Println(v.Name)
4141
}
4242
}

examples/people/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func main() {
3636
}
3737

3838
// Images - Iterate profiles from append to response.
39-
for _, v := range person.PersonImagesAppend.Images.Profiles {
39+
for _, v := range person.Images.Profiles {
4040
fmt.Println(v.FilePath)
4141
}
4242
}

examples/search/main.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ func main() {
2626

2727
// Iterate
2828
for _, v := range search.Results {
29-
if v.MediaType == "movie" {
29+
switch v.MediaType {
30+
case "movie":
3031
fmt.Println("Movie Title: ", v.Title)
31-
} else if v.MediaType == "tv" {
32+
case "tv":
3233
fmt.Println("TV Show: ", v.Name)
33-
} else if v.MediaType == "person" {
34+
case "person":
3435
fmt.Println("Person: ", v.Name)
3536
}
3637
}

examples/tv/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func main() {
3636
}
3737

3838
// Credits - Iterate cast from append to response.
39-
for _, v := range tvShow.TVCreditsAppend.Credits.Cast {
39+
for _, v := range tvShow.Credits.Cast {
4040
fmt.Println(v.Name)
4141
}
4242
}

examples/withAutoRetry/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func main() {
4040
}
4141

4242
// Credits - Iterate cast from append to response.
43-
for _, v := range movie.MovieCreditsAppend.Credits.Cast {
43+
for _, v := range movie.Credits.Cast {
4444
fmt.Println(v.Name)
4545
}
4646
}

0 commit comments

Comments
 (0)