Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change GITHUB_TOKEN to GITHUB_TOKENS in tests #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ env:
- PSQL_USER=user
- PSQL_PWD=password
- PSQL_DB=ghsync
- GITHUB_TOKENS=$GITHUB_TOKEN

branches:
only:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ To test, run:

```shell
# set your github personal access token (scopes 'read:org', 'repo')
export GITHUB_TOKEN=<xxx>
export GITHUB_TOKENS=<xxx>

# start the database if not already running
export POSTGRES_USER=user
Expand Down
3 changes: 2 additions & 1 deletion examples/cmd/testing/recordingscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"net/http"
"os"
"path/filepath"
"strings"
"time"

"github.com/src-d/metadata-retrieval/github"
Expand Down Expand Up @@ -46,7 +47,7 @@ func main() {
client := oauth2.NewClient(
ctx,
oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
&oauth2.Token{AccessToken: strings.Split(os.Getenv("GITHUB_TOKENS"), ",")[0]},
))

client.Transport = &loghttp.Transport{
Expand Down
10 changes: 5 additions & 5 deletions github/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ func loadTests(filepath string) (testutils.TestOracles, error) {

// checks whether a token exists as an env var, if not it skips the test
func checkToken(t *testing.T) {
if os.Getenv("GITHUB_TOKEN") == "" {
t.Skip("GITHUB_TOKEN is not set")
if strings.Split(os.Getenv("GITHUB_TOKENS"), ",")[0] == "" {
t.Skip("GITHUB_TOKENS is not set")
}
}

Expand Down Expand Up @@ -130,7 +130,7 @@ func getMemoryDownloader() (*Downloader, *testutils.Memory, error) {
oauth2.NewClient(
context.TODO(),
oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
&oauth2.Token{AccessToken: strings.Split(os.Getenv("GITHUB_TOKENS"), ",")[0]},
)),
storer)
if err != nil {
Expand Down Expand Up @@ -359,7 +359,7 @@ func (suite *DownloaderTestSuite) TestOnlineOrganizationDownloadWithDB() {
downloader, err := NewDownloader(oauth2.NewClient(
context.TODO(),
oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
&oauth2.Token{AccessToken: strings.Split(os.Getenv("GITHUB_TOKENS"), ",")[0]},
)), store.NewDB(suite.db))
suite.NoError(err, "Failed to init the downloader")
downloader.SetCurrent(context.TODO(), 0)
Expand Down Expand Up @@ -458,7 +458,7 @@ func (suite *DownloaderTestSuite) TestOnlineRepositoryDownloadWithDB() {
downloader, err := NewDownloader(oauth2.NewClient(
context.TODO(),
oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: os.Getenv("GITHUB_TOKEN")},
&oauth2.Token{AccessToken: strings.Split(os.Getenv("GITHUB_TOKENS"), ",")[0]},
)), store.NewDB(suite.db))
suite.NoError(err, "Failed to init the downloader")
downloader.SetCurrent(context.TODO(), 0)
Expand Down