-
Notifications
You must be signed in to change notification settings - Fork 35
/
authentication_test.go
41 lines (34 loc) · 1.34 KB
/
authentication_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
package tmdb
func (suite *TMBDTestSuite) TestCreateGuestSession() {
rt, err := suite.client.CreateGuestSession()
suite.Nil(err)
suite.Equal(true, rt.Success)
}
func (suite *TMBDTestSuite) TestCreateGuestSessionFail() {
suite.client.apiKey = ""
_, err := suite.client.CreateGuestSession()
suite.Equal("code: 7 | success: false | message: Invalid API key: You must be granted a valid key.", err.Error())
}
func (suite *TMBDTestSuite) TestCreateRequestToken() {
rt, err := suite.client.CreateRequestToken()
suite.Nil(err)
suite.Equal(true, rt.Success)
}
func (suite *TMBDTestSuite) TestCreateRequestTokenFail() {
suite.client.apiKey = ""
_, err := suite.client.CreateRequestToken()
suite.Equal("code: 7 | success: false | message: Invalid API key: You must be granted a valid key.", err.Error())
}
// TODO: How to validate a token that needs a browser?
// func (suite *TMBDTestSuite) TestCreateSession() {
// }
// func (suite *TMBDTestSuite) TestCreateSessionDenied() {
// session, err := suite.CreateSession("kpaishQpkpfVmbi")
// suite.Nil(session)
// suite.Equal("Session denied.", err.Error())
// }
// func (suite *TMBDTestSuite) TestCreateSessionFail() {
// suite.client.apiKey = ""
// _, err := suite.CreateRequestToken()
// suite.Equal("code: 7 | success: false | message: Invalid API key: You must be granted a valid key.", err.Error())
// }