forked from ryanbradynd05/go-tmdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
60 lines (51 loc) · 1.25 KB
/
main_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
package tmdb
import (
"fmt"
"os"
"strconv"
"strings"
"testing"
"github.com/kylelemons/go-gypsy/yaml"
. "gopkg.in/check.v1"
)
func Test(t *testing.T) { TestingT(t) }
type TmdbSuite struct {
tmdb *TMDb
userToken string
user string
pw string
session string
guestSession string
accountID int
}
var _ = Suite(&TmdbSuite{})
func (s *TmdbSuite) KeyConfig(apiKey string) Config {
testKeyConfig := Config{
APIKey: apiKey,
Proxies: nil,
UseProxy: false,
}
return testKeyConfig
}
func (s *TmdbSuite) SetUpSuite(c *C) {
pwd, _ := os.Getwd()
basedir := strings.SplitAfter(pwd, "ryanbradynd05/go-tmdb")
filename := fmt.Sprintf("%s/local.yml", basedir[0])
config, _ := yaml.ReadFile(filename)
s.userToken, _ = config.Get("userToken")
s.user, _ = config.Get("user")
s.pw, _ = config.Get("pw")
s.session, _ = config.Get("session")
s.guestSession, _ = config.Get("guestSession")
accountID, _ := config.Get("accountID")
s.accountID, _ = strconv.Atoi(accountID)
key, _ := config.Get("testKey")
testKey := s.KeyConfig(key)
s.tmdb = Init(testKey)
}
func (s *TmdbSuite) baseTest(input interface{}, err error, c *C) {
c.Assert(err, IsNil)
jsonRes, err := ToJSON(input)
c.Assert(err, IsNil)
c.Assert(jsonRes, NotNil)
}