-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathlist_test.go
123 lines (107 loc) · 3.58 KB
/
list_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
123
package tmdb
// const listID = "50941077760ee35e1500000c"
const listID = 1
func (suite *TMBDTestSuite) TestGetListDetails() {
list, err := suite.client.GetListDetails(listID, nil)
suite.Nil(err)
suite.NotNil(list.ID)
}
func (suite *TMBDTestSuite) TestGetListDetailsFail() {
suite.client.apiKey = ""
_, err := suite.client.GetListDetails(listID, nil)
suite.NotNil(err)
}
func (suite *TMBDTestSuite) TestGetListDetailsWithOptions() {
options := make(map[string]string)
options["language"] = "pt-BR"
list, err := suite.client.GetListDetails(listID, options)
suite.Nil(err)
suite.NotNil(list.ID)
}
func (suite *TMBDTestSuite) TestGetListItemStatus() {
options := make(map[string]string)
options["movie_id"] = "10658"
list, err := suite.client.GetListItemStatus(listID, options)
suite.Nil(err)
suite.NotNil(list.ID)
}
func (suite *TMBDTestSuite) TestGetListItemStatusFail() {
suite.client.apiKey = ""
options := make(map[string]string)
options["movie_id"] = "10658"
_, err := suite.client.GetListItemStatus(listID, options)
suite.NotNil(err)
}
// Commented because this test creates a lots of repeated lists
// on my account.
//
// func (suite *TMBDTestSuite) TestCreateList() {
// suite.client.SetSessionID(sessionID)
// createList := ListCreate{
// Name: "Test list!",
// Description: "Description is not enough...",
// Language: "en",
// }
// response, err := suite.client.CreateList(&createList)
// suite.Nil(err)
// suite.NotNil(response.StatusMessage)
// }
func (suite *TMBDTestSuite) TestCreateListFail() {
suite.client.sessionID = ""
createList := ListCreate{
Name: "Wrapper test list",
Description: "This is a description",
Language: "en",
}
_, err := suite.client.CreateList(&createList)
suite.NotNil(err)
}
func (suite *TMBDTestSuite) TestClearList() {
suite.client.SetSessionID(sessionID)
_, err := suite.client.ClearList(128331, true)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
}
func (suite *TMBDTestSuite) TestClearListFail() {
suite.client.sessionID = ""
_, err := suite.client.ClearList(128331, true)
suite.NotNil(err)
}
func (suite *TMBDTestSuite) TestDeleteList() {
suite.client.SetSessionID(sessionID)
_, err := suite.client.DeleteList(128331)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
}
func (suite *TMBDTestSuite) TestDeleteListFail() {
suite.client.sessionID = ""
createList := ListCreate{
Name: "Wrapper test list",
Description: "This is a description",
Language: "en",
}
_, err := suite.client.CreateList(&createList)
suite.NotNil(err)
}
func (suite *TMBDTestSuite) TestAddMovie() {
suite.client.SetSessionID(sessionID)
mediaID := ListMedia{MediaID: 500}
_, err := suite.client.AddMovie(128331, &mediaID)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
}
func (suite *TMBDTestSuite) TestAddMovieFail() {
suite.client.sessionID = ""
mediaID := ListMedia{MediaID: 500}
_, err := suite.client.AddMovie(128331, &mediaID)
suite.NotNil(err)
}
func (suite *TMBDTestSuite) TestRemoveMovie() {
suite.client.SetSessionID(sessionID)
mediaID := ListMedia{MediaID: 500}
_, err := suite.client.RemoveMovie(128331, &mediaID)
suite.Equal("code: 34 | success: false | message: The resource you requested could not be found.", err.Error())
}
func (suite *TMBDTestSuite) TestRemoveMovieFail() {
suite.client.sessionID = ""
mediaID := ListMedia{MediaID: 500}
_, err := suite.client.RemoveMovie(128331, &mediaID)
suite.NotNil(err)
}