From 5be2c1f7294c714dcfce82b6d7ab7f1df52a8f1d Mon Sep 17 00:00:00 2001 From: Will Norris Date: Thu, 30 May 2013 10:14:56 -0700 Subject: [PATCH] test invalid URL on repo creation Also properly return a 204 response on methods that don't include a response body. This has no actual effect on current tests, but more accurately reflects what the GitHub API really returns and might make a difference in the future. --- github/orgs_test.go | 7 +++++++ github/repos_test.go | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/github/orgs_test.go b/github/orgs_test.go index fd958e6..dd53269 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -219,6 +219,7 @@ func TestOrganizationsService_CheckMembership(t *testing.T) { if m := "GET"; m != r.Method { t.Errorf("Request method = %v, want %v", r.Method, m) } + w.WriteHeader(http.StatusNoContent) }) member, err := client.Organizations.CheckMembership("o", "u") @@ -294,6 +295,7 @@ func TestOrganizationsService_CheckPublicMembership(t *testing.T) { if m := "GET"; m != r.Method { t.Errorf("Request method = %v, want %v", r.Method, m) } + w.WriteHeader(http.StatusNoContent) }) member, err := client.Organizations.CheckPublicMembership("o", "u") @@ -634,6 +636,7 @@ func TestOrganizationsService_AddTeamMember(t *testing.T) { if m := "PUT"; m != r.Method { t.Errorf("Request method = %v, want %v", r.Method, m) } + w.WriteHeader(http.StatusNoContent) }) err := client.Organizations.AddTeamMember(1, "u") @@ -660,6 +663,7 @@ func TestOrganizationsService_RemoveTeamMember(t *testing.T) { if m := "DELETE"; m != r.Method { t.Errorf("Request method = %v, want %v", r.Method, m) } + w.WriteHeader(http.StatusNoContent) }) err := client.Organizations.RemoveTeamMember(1, "u") @@ -686,6 +690,7 @@ func TestOrganizationsService_PublicizeMembership(t *testing.T) { if m := "PUT"; m != r.Method { t.Errorf("Request method = %v, want %v", r.Method, m) } + w.WriteHeader(http.StatusNoContent) }) err := client.Organizations.PublicizeMembership("o", "u") @@ -712,6 +717,7 @@ func TestOrganizationsService_ConcealMembership(t *testing.T) { if m := "DELETE"; m != r.Method { t.Errorf("Request method = %v, want %v", r.Method, m) } + w.WriteHeader(http.StatusNoContent) }) err := client.Organizations.ConcealMembership("o", "u") @@ -760,6 +766,7 @@ func TestOrganizationsService_CheckTeamRepo_true(t *testing.T) { if m := "GET"; m != r.Method { t.Errorf("Request method = %v, want %v", r.Method, m) } + w.WriteHeader(http.StatusNoContent) }) managed, err := client.Organizations.CheckTeamRepo(1, "o", "r") diff --git a/github/repos_test.go b/github/repos_test.go index 3195d45..29aeec2 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -216,6 +216,16 @@ func TestRepositoriesService_Create_org(t *testing.T) { } } +func TestRepositoriesService_Create_invalidOrg(t *testing.T) { + _, err := client.Repositories.Create("%", nil) + if err == nil { + t.Errorf("Expected error to be returned") + } + if err, ok := err.(*url.Error); !ok { + t.Errorf("Expected URL parse error, got %+v", err) + } +} + func TestRepositoriesService_Get(t *testing.T) { setup() defer teardown()