diff --git a/tests/fields/fields.go b/tests/fields/fields.go index 666d432..67e4050 100644 --- a/tests/fields/fields.go +++ b/tests/fields/fields.go @@ -24,8 +24,8 @@ import ( "reflect" "strings" - "code.google.com/p/goauth2/oauth" "github.com/google/go-github/github" + "golang.org/x/oauth2" ) var ( @@ -38,6 +38,16 @@ var ( skipURLs = flag.Bool("skip_urls", false, "skip url fields") ) +// tokenSource is an oauth2.TokenSource which returns a static access token +type tokenSource struct { + token *oauth2.Token +} + +// Token implements the oauth2.TokenSource interface +func (t *tokenSource) Token() (*oauth2.Token, error) { + return t.token, nil +} + func main() { flag.Parse() @@ -46,10 +56,10 @@ func main() { print("!!! No OAuth token. Some tests won't run. !!!\n\n") client = github.NewClient(nil) } else { - t := &oauth.Transport{ - Token: &oauth.Token{AccessToken: token}, - } - client = github.NewClient(t.Client()) + tc := oauth2.NewClient(oauth2.NoContext, &tokenSource{ + &oauth2.Token{AccessToken: token}, + }) + client = github.NewClient(tc) auth = true } diff --git a/tests/integration/github_test.go b/tests/integration/github_test.go index db31f19..14376b9 100644 --- a/tests/integration/github_test.go +++ b/tests/integration/github_test.go @@ -13,8 +13,8 @@ import ( "fmt" "os" - "code.google.com/p/goauth2/oauth" "github.com/google/go-github/github" + "golang.org/x/oauth2" ) var ( @@ -25,16 +25,26 @@ var ( auth bool ) +// tokenSource is an oauth2.TokenSource which returns a static access token +type tokenSource struct { + token *oauth2.Token +} + +// Token implements the oauth2.TokenSource interface +func (t *tokenSource) Token() (*oauth2.Token, error) { + return t.token, nil +} + func init() { token := os.Getenv("GITHUB_AUTH_TOKEN") if token == "" { print("!!! No OAuth token. Some tests won't run. !!!\n\n") client = github.NewClient(nil) } else { - t := &oauth.Transport{ - Token: &oauth.Token{AccessToken: token}, - } - client = github.NewClient(t.Client()) + tc := oauth2.NewClient(oauth2.NoContext, &tokenSource{ + &oauth2.Token{AccessToken: token}, + }) + client = github.NewClient(tc) auth = true } }