From 8df7d0326012c323c540355b34c4d245b10bc766 Mon Sep 17 00:00:00 2001 From: Ryan Brady Date: Mon, 9 Feb 2015 20:17:45 -0500 Subject: [PATCH] Add local.yml to hold auth info --- .gitignore | 2 ++ account_test.go | 18 +++++++++--------- authentication_test.go | 13 ++----------- coverage/coverage_report.html | 2 +- guestsessions_test.go | 2 +- local.yml.example | 6 ++++++ main_test.go | 24 +++++++++++++++++++++++- movies_test.go | 2 +- tv_test.go | 2 +- 9 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 local.yml.example diff --git a/.gitignore b/.gitignore index daf913b..72127f6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,5 @@ _testmain.go *.exe *.test *.prof + +local.yml diff --git a/account_test.go b/account_test.go index c3367dc..1792820 100644 --- a/account_test.go +++ b/account_test.go @@ -5,42 +5,42 @@ import ( ) func (s *TmdbSuite) TestGetAccountInfo(c *C) { - result, err := s.tmdb.GetAccountInfo(session) + result, err := s.tmdb.GetAccountInfo(s.session) s.baseTest(&result, err, c) - c.Assert(result.Username, Equals, user) + c.Assert(result.Username, Equals, s.user) } func (s *TmdbSuite) TestGetAccountLists(c *C) { - result, err := s.tmdb.GetAccountLists(accountID, session, nil) + result, err := s.tmdb.GetAccountLists(s.accountID, s.session, nil) s.baseTest(&result, err, c) } func (s *TmdbSuite) TestGetAccountFavoriteMovies(c *C) { - result, err := s.tmdb.GetAccountFavoriteMovies(accountID, session, nil) + result, err := s.tmdb.GetAccountFavoriteMovies(s.accountID, s.session, nil) s.baseTest(&result, err, c) } func (s *TmdbSuite) TestGetAccountFavoriteTv(c *C) { - result, err := s.tmdb.GetAccountFavoriteTv(accountID, session, nil) + result, err := s.tmdb.GetAccountFavoriteTv(s.accountID, s.session, nil) s.baseTest(&result, err, c) } func (s *TmdbSuite) TestGetAccountRatedMovies(c *C) { - result, err := s.tmdb.GetAccountRatedMovies(accountID, session, nil) + result, err := s.tmdb.GetAccountRatedMovies(s.accountID, s.session, nil) s.baseTest(&result, err, c) } func (s *TmdbSuite) TestGetAccountRatedTv(c *C) { - result, err := s.tmdb.GetAccountRatedTv(accountID, session, nil) + result, err := s.tmdb.GetAccountRatedTv(s.accountID, s.session, nil) s.baseTest(&result, err, c) } func (s *TmdbSuite) TestGetAccountWatchlistMovies(c *C) { - result, err := s.tmdb.GetAccountWatchlistMovies(accountID, session, nil) + result, err := s.tmdb.GetAccountWatchlistMovies(s.accountID, s.session, nil) s.baseTest(&result, err, c) } func (s *TmdbSuite) TestGetAccountWatchlistTv(c *C) { - result, err := s.tmdb.GetAccountWatchlistTv(accountID, session, nil) + result, err := s.tmdb.GetAccountWatchlistTv(s.accountID, s.session, nil) s.baseTest(&result, err, c) } diff --git a/authentication_test.go b/authentication_test.go index 98f5d3c..2fdb568 100644 --- a/authentication_test.go +++ b/authentication_test.go @@ -4,27 +4,18 @@ import ( . "gopkg.in/check.v1" ) -const ( - userToken string = "" - user string = "" - pw string = "" - session string = "" - guestSession string = "" - accountID int = 0 -) - func (s *TmdbSuite) TestGetAuthToken(c *C) { result, err := s.tmdb.GetAuthToken() s.baseTest(&result, err, c) } func (s *TmdbSuite) TestGetAuthValidateToken(c *C) { - result, err := s.tmdb.GetAuthValidateToken(userToken, user, pw) + result, err := s.tmdb.GetAuthValidateToken(s.userToken, s.user, s.pw) s.baseTest(&result, err, c) } func (s *TmdbSuite) TestGetAuthSession(c *C) { - result, err := s.tmdb.GetAuthSession(userToken) + result, err := s.tmdb.GetAuthSession(s.userToken) s.baseTest(&result, err, c) } diff --git a/coverage/coverage_report.html b/coverage/coverage_report.html index fde7f34..72768a0 100644 --- a/coverage/coverage_report.html +++ b/coverage/coverage_report.html @@ -128,7 +128,7 @@
Coverage Report
-
Generated on 09 Feb 15 13:45 -0500 with gocov-html
Package Overview: github.com/ryanbradynd05/go-tmdb 100.00%

This is a coverage report created after analysis of the github.com/ryanbradynd05/go-tmdb package. It +

Generated on 09 Feb 15 20:17 -0500 with gocov-html
Package Overview: github.com/ryanbradynd05/go-tmdb 100.00%

This is a coverage report created after analysis of the github.com/ryanbradynd05/go-tmdb package. It has been generated with the following command:

gocov test github.com/ryanbradynd05/go-tmdb | gocov-html

Here are the stats. Please select a function name to view its implementation and see what's left for testing.

diff --git a/guestsessions_test.go b/guestsessions_test.go index ad7e139..c2ee013 100644 --- a/guestsessions_test.go +++ b/guestsessions_test.go @@ -5,6 +5,6 @@ import ( ) func (s *TmdbSuite) TestGetGuestSessionRatedMovies(c *C) { - result, err := s.tmdb.GetGuestSessionRatedMovies(guestSession, nil) + result, err := s.tmdb.GetGuestSessionRatedMovies(s.guestSession, nil) s.baseTest(&result, err, c) } diff --git a/local.yml.example b/local.yml.example new file mode 100644 index 0000000..c09cc5c --- /dev/null +++ b/local.yml.example @@ -0,0 +1,6 @@ +userToken: "" +user: "" +pw: "" +session: "" +guestSession: "" +accountID: 0 \ No newline at end of file diff --git a/main_test.go b/main_test.go index d07fc46..8f082a1 100644 --- a/main_test.go +++ b/main_test.go @@ -1,7 +1,12 @@ package tmdb import ( + "fmt" + "github.com/kylelemons/go-gypsy/yaml" . "gopkg.in/check.v1" + "os" + "strconv" + "strings" "testing" ) @@ -10,12 +15,29 @@ const testKey string = "b12bd26ee15e6972f2f4c03363b74fa2" func Test(t *testing.T) { TestingT(t) } type TmdbSuite struct { - tmdb *TMDb + tmdb *TMDb + userToken string + user string + pw string + session string + guestSession string + accountID int } var _ = Suite(&TmdbSuite{}) 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) s.tmdb = Init(testKey) } diff --git a/movies_test.go b/movies_test.go index b0fe0a0..7b9838d 100644 --- a/movies_test.go +++ b/movies_test.go @@ -34,7 +34,7 @@ func (s *TmdbSuite) TestGetMovieInfo(c *C) { } func (s *TmdbSuite) TestGetMovieAccountStates(c *C) { - result, err := s.tmdb.GetMovieAccountStates(fightClubID, session) + result, err := s.tmdb.GetMovieAccountStates(fightClubID, s.session) s.baseTest(&result, err, c) } diff --git a/tv_test.go b/tv_test.go index fbf061e..cc3e267 100644 --- a/tv_test.go +++ b/tv_test.go @@ -37,7 +37,7 @@ func (s *TmdbSuite) TestGetTvInfo(c *C) { } func (s *TmdbSuite) TestGetTvAccountStates(c *C) { - result, err := s.tmdb.GetTvAccountStates(gameOfThronesID, session) + result, err := s.tmdb.GetTvAccountStates(gameOfThronesID, s.session) s.baseTest(&result, err, c) }
TMDb.SearchTv(...)github.com/ryanbradynd05/go-tmdb/search.go100.00%7/7
TMDb.SearchKeyword(...)github.com/ryanbradynd05/go-tmdb/search.go100.00%7/7