Browse Source

add test for getting authenticated user

Will Norris 12 years ago
parent
commit
4548bd66d1
2 changed files with 25 additions and 3 deletions
  1. +9
    -1
      tests/integration/github_test.go
  2. +16
    -2
      tests/integration/users_test.go

+ 9
- 1
tests/integration/github_test.go View File

@ -11,9 +11,10 @@
package tests
import (
"fmt"
"os"
"code.google.com/p/goauth2/oauth"
"code.google.com/p/goauth2/oauth"
"github.com/google/go-github/github"
)
@ -38,3 +39,10 @@ func init() {
auth = true
}
}
func checkAuth(name string) bool {
if !auth {
fmt.Printf("No auth - skipping portions of %v\n", name)
}
return auth
}

+ 16
- 2
tests/integration/users_test.go View File

@ -5,7 +5,10 @@
package tests
import "testing"
import (
"fmt"
"testing"
)
func TestUsers_List(t *testing.T) {
u, _, err := client.Users.ListAll(nil)
@ -26,7 +29,7 @@ func TestUsers_List(t *testing.T) {
func TestUsers_Get(t *testing.T) {
u, _, err := client.Users.Get("octocat")
if err != nil {
t.Fatalf("Users.Get returned error: %v", err)
t.Fatalf("Users.Get('octocat') returned error: %v", err)
}
if want := "octocat"; want != *u.Login {
@ -35,4 +38,15 @@ func TestUsers_Get(t *testing.T) {
if want := "The Octocat"; want != *u.Name {
t.Errorf("user.Name was %q, wanted %q", *u.Name, want)
}
if checkAuth("TestUsers_Get") {
u, _, err := client.Users.Get("")
if err != nil {
t.Fatalf("Users.Get('') returned error: %v", err)
}
if *u.Login == "" {
t.Errorf("wanted non-empty values for user.Login")
}
}
}

Loading…
Cancel
Save