diff --git a/tests/integration/github_test.go b/tests/integration/github_test.go index 6e31d88..8110c11 100644 --- a/tests/integration/github_test.go +++ b/tests/integration/github_test.go @@ -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 +} diff --git a/tests/integration/users_test.go b/tests/integration/users_test.go index 3387bf0..947f708 100644 --- a/tests/integration/users_test.go +++ b/tests/integration/users_test.go @@ -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") + } + } }