Skip to content

Commit

Permalink
Add local.yml to hold auth info
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanbradynd05 committed Feb 10, 2015
1 parent 3674573 commit 8df7d03
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ _testmain.go
*.exe
*.test
*.prof

local.yml
18 changes: 9 additions & 9 deletions account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
13 changes: 2 additions & 11 deletions authentication_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion coverage/coverage_report.html
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
</head>
<body>
<div id="doctitle">Coverage Report</div>
<div id="about">Generated on 09 Feb 15 13:45 -0500 with <a href="https://github.com/matm/gocov-html">gocov-html</a></div><div id="pkg_github.com/ryanbradynd05/go-tmdb" class="funcname">Package Overview: github.com/ryanbradynd05/go-tmdb <span class="packageTotal">100.00%</span></div><p>This is a coverage report created after analysis of the <code>github.com/ryanbradynd05/go-tmdb</code> package. It
<div id="about">Generated on 09 Feb 15 20:17 -0500 with <a href="https://github.com/matm/gocov-html">gocov-html</a></div><div id="pkg_github.com/ryanbradynd05/go-tmdb" class="funcname">Package Overview: github.com/ryanbradynd05/go-tmdb <span class="packageTotal">100.00%</span></div><p>This is a coverage report created after analysis of the <code>github.com/ryanbradynd05/go-tmdb</code> package. It
has been generated with the following command:</p><pre class="cmd">gocov test github.com/ryanbradynd05/go-tmdb | gocov-html</pre> <p>Here are the stats. Please select a function name to view its implementation and see what's left for testing.</p><table class="overview">
<tr id="s_fn_TMDb.SearchTv"><td><code><a href="#fn_TMDb.SearchTv">TMDb.SearchTv(...)</a></code></td><td><code>github.com/ryanbradynd05/go-tmdb/search.go</code></td><td class="percent"><code>100.00%</code></td><td class="linecount"><code>7/7</code></td></tr>
<tr id="s_fn_TMDb.SearchKeyword"><td><code><a href="#fn_TMDb.SearchKeyword">TMDb.SearchKeyword(...)</a></code></td><td><code>github.com/ryanbradynd05/go-tmdb/search.go</code></td><td class="percent"><code>100.00%</code></td><td class="linecount"><code>7/7</code></td></tr>
Expand Down
2 changes: 1 addition & 1 deletion guestsessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
6 changes: 6 additions & 0 deletions local.yml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
userToken: ""
user: ""
pw: ""
session: ""
guestSession: ""
accountID: 0
24 changes: 23 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package tmdb

import (
"fmt"
"github.com/kylelemons/go-gypsy/yaml"
. "gopkg.in/check.v1"
"os"
"strconv"
"strings"
"testing"
)

Expand All @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion movies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion tv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down

0 comments on commit 8df7d03

Please sign in to comment.