Browse Source

add tests for URL parse errors

These tests exercise the code path in all of our API methods where an
error is returned from github.NewRequest().  There are actually only two
ways to trigger an error here:
 - provide a URL which can't be parsed
 - provide a request body which can't be JSON encoded

In theory, it's also possible that http.NewRequest() could return an
error which would make its way up the stack, but in practice this will
never happen.  That's because http.NewRequest(), as currently
implemented, will only ever return an error if it's unable to parse the
provided URL.  But since we're simply passing the output of
URL.String(), we know that it will never be unparseable.  That leaves
the two options above.

For methods that don't have a request body (which is to say, most), all
we can do is force a URL parse error, which is most easily accomplished
by putting an unescaped "%" in the URL path.  This works for methods
that take a string input parameter that is directly added to the path.
If there are no string parameters to the function, or if they're not
part of the URL path, then we're mostly out of luck.  In some of those
cases, we can still try to force a JSON encoding error, but otherwise
there will be no way to exercise this code path in those methods.

Of course in this case, the fact that we can't test the error case means
that the error case isn't actually possible.  Nevertheless, I don't want
to ignore the error entirely in case some future change in the
implementation of github.NewRequest() or http.NewRequest() might
introduce a new possibility for erroring out.

What we're testing here is not likely to be a common error case, and
adding all of these tests to check for it in each method may be a bit
OCD, but I'd rather have the test coverage.
Will Norris 12 years ago
parent
commit
0392f18ad8
14 changed files with 306 additions and 5 deletions
  1. +35
    -1
      github/activity_events_test.go
  2. +5
    -0
      github/activity_star_test.go
  3. +25
    -0
      github/gists_comments_test.go
  4. +42
    -2
      github/gists_test.go
  5. +10
    -0
      github/git_commits_test.go
  6. +10
    -0
      github/git_trees_test.go
  7. +12
    -0
      github/github_test.go
  8. +55
    -0
      github/issues_labels_test.go
  9. +20
    -0
      github/repos_collaborators_test.go
  10. +30
    -0
      github/repos_comments_test.go
  11. +30
    -0
      github/repos_hooks_test.go
  12. +20
    -0
      github/repos_keys_test.go
  13. +7
    -2
      github/repos_test.go
  14. +5
    -0
      github/search_test.go

+ 35
- 1
github/activity_events_test.go View File

@ -61,6 +61,11 @@ func TestActivityService_ListRepositoryEvents(t *testing.T) {
}
}
func TestActivityService_ListRepositoryEvents_invalidOwner(t *testing.T) {
_, _, err := client.Activity.ListRepositoryEvents("%", "%", nil)
testURLParseError(t, err)
}
func TestActivityService_ListIssueEventsForRepository(t *testing.T) {
setup()
defer teardown()
@ -85,6 +90,11 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) {
}
}
func TestActivityService_ListIssueEventsForRepository_invalidOwner(t *testing.T) {
_, _, err := client.Activity.ListIssueEventsForRepository("%", "%", nil)
testURLParseError(t, err)
}
func TestActivityService_ListEventsForRepoNetwork(t *testing.T) {
setup()
defer teardown()
@ -109,6 +119,11 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) {
}
}
func TestActivityService_ListEventsForRepoNetwork_invalidOwner(t *testing.T) {
_, _, err := client.Activity.ListEventsForRepoNetwork("%", "%", nil)
testURLParseError(t, err)
}
func TestActivityService_ListEventsForOrganization(t *testing.T) {
setup()
defer teardown()
@ -133,6 +148,11 @@ func TestActivityService_ListEventsForOrganization(t *testing.T) {
}
}
func TestActivityService_ListEventsForOrganization_invalidOrg(t *testing.T) {
_, _, err := client.Activity.ListEventsForOrganization("%", nil)
testURLParseError(t, err)
}
func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) {
setup()
defer teardown()
@ -177,6 +197,11 @@ func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) {
}
}
func TestActivityService_ListEventsPerformedByUser_invalidUser(t *testing.T) {
_, _, err := client.Activity.ListEventsPerformedByUser("%", false, nil)
testURLParseError(t, err)
}
func TestActivityService_ListEventsRecievedByUser_all(t *testing.T) {
setup()
defer teardown()
@ -221,16 +246,25 @@ func TestActivityService_ListEventsRecievedByUser_publicOnly(t *testing.T) {
}
}
func TestActivityService_ListEventsRecievedByUser_invalidUser(t *testing.T) {
_, _, err := client.Activity.ListEventsRecievedByUser("%", false, nil)
testURLParseError(t, err)
}
func TestActivityService_ListUserEventsForOrganization(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/users/u/events/orgs/o", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{
"page": "2",
})
fmt.Fprint(w, `[{"id":"1"},{"id":"2"}]`)
})
events, _, err := client.Activity.ListUserEventsForOrganization("o", "u", nil)
opt := &ListOptions{Page: 2}
events, _, err := client.Activity.ListUserEventsForOrganization("o", "u", opt)
if err != nil {
t.Errorf("Activities.ListUserEventsForOrganization returned error: %v", err)
}


+ 5
- 0
github/activity_star_test.go View File

@ -57,3 +57,8 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) {
t.Errorf("Activity.ListStarred returned %+v, want %+v", repos, want)
}
}
func TestActivityService_ListStarred_invalidUser(t *testing.T) {
_, _, err := client.Activity.ListStarred("%", nil)
testURLParseError(t, err)
}

+ 25
- 0
github/gists_comments_test.go View File

@ -34,6 +34,11 @@ func TestGistsService_ListComments(t *testing.T) {
}
}
func TestGistsService_ListComments_invalidID(t *testing.T) {
_, _, err := client.Gists.ListComments("%")
testURLParseError(t, err)
}
func TestGistsService_GetComment(t *testing.T) {
setup()
defer teardown()
@ -55,6 +60,11 @@ func TestGistsService_GetComment(t *testing.T) {
}
}
func TestGistsService_GetComment_invalidID(t *testing.T) {
_, _, err := client.Gists.GetComment("%", 1)
testURLParseError(t, err)
}
func TestGistsService_CreateComment(t *testing.T) {
setup()
defer teardown()
@ -84,6 +94,11 @@ func TestGistsService_CreateComment(t *testing.T) {
}
}
func TestGistsService_CreateComment_invalidID(t *testing.T) {
_, _, err := client.Gists.CreateComment("%", nil)
testURLParseError(t, err)
}
func TestGistsService_EditComment(t *testing.T) {
setup()
defer teardown()
@ -113,6 +128,11 @@ func TestGistsService_EditComment(t *testing.T) {
}
}
func TestGistsService_EditComment_invalidID(t *testing.T) {
_, _, err := client.Gists.EditComment("%", 1, nil)
testURLParseError(t, err)
}
func TestGistsService_DeleteComment(t *testing.T) {
setup()
defer teardown()
@ -126,3 +146,8 @@ func TestGistsService_DeleteComment(t *testing.T) {
t.Errorf("Gists.Delete returned error: %v", err)
}
}
func TestGistsService_DeleteComment_invalidID(t *testing.T) {
_, err := client.Gists.DeleteComment("%", 1)
testURLParseError(t, err)
}

+ 42
- 2
github/gists_test.go View File

@ -14,7 +14,7 @@ import (
"time"
)
func TestGistsService_List(t *testing.T) {
func TestGistsService_List_specifiedUser(t *testing.T) {
setup()
defer teardown()
@ -41,7 +41,7 @@ func TestGistsService_List(t *testing.T) {
}
}
func TestGistsService_List_withEmptyUser(t *testing.T) {
func TestGistsService_List_authenticatedUser(t *testing.T) {
setup()
defer teardown()
@ -61,6 +61,11 @@ func TestGistsService_List_withEmptyUser(t *testing.T) {
}
}
func TestGistsService_List_invalidUser(t *testing.T) {
_, _, err := client.Gists.List("%", nil)
testURLParseError(t, err)
}
func TestGistsService_ListAll(t *testing.T) {
setup()
defer teardown()
@ -136,6 +141,11 @@ func TestGistsService_Get(t *testing.T) {
}
}
func TestGistsService_Get_invalidID(t *testing.T) {
_, _, err := client.Gists.Get("%")
testURLParseError(t, err)
}
func TestGistsService_Create(t *testing.T) {
setup()
defer teardown()
@ -245,6 +255,11 @@ func TestGistsService_Edit(t *testing.T) {
}
}
func TestGistsService_Edit_invalidID(t *testing.T) {
_, _, err := client.Gists.Edit("%", nil)
testURLParseError(t, err)
}
func TestGistsService_Delete(t *testing.T) {
setup()
defer teardown()
@ -259,6 +274,11 @@ func TestGistsService_Delete(t *testing.T) {
}
}
func TestGistsService_Delete_invalidID(t *testing.T) {
_, err := client.Gists.Delete("%")
testURLParseError(t, err)
}
func TestGistsService_Star(t *testing.T) {
setup()
defer teardown()
@ -273,6 +293,11 @@ func TestGistsService_Star(t *testing.T) {
}
}
func TestGistsService_Star_invalidID(t *testing.T) {
_, err := client.Gists.Star("%")
testURLParseError(t, err)
}
func TestGistsService_Unstar(t *testing.T) {
setup()
defer teardown()
@ -287,6 +312,11 @@ func TestGistsService_Unstar(t *testing.T) {
}
}
func TestGistsService_Unstar_invalidID(t *testing.T) {
_, err := client.Gists.Unstar("%")
testURLParseError(t, err)
}
func TestGistsService_IsStarred_hasStar(t *testing.T) {
setup()
defer teardown()
@ -323,6 +353,11 @@ func TestGistsService_IsStarred_noStar(t *testing.T) {
}
}
func TestGistsService_IsStarred_invalidID(t *testing.T) {
_, _, err := client.Gists.IsStarred("%")
testURLParseError(t, err)
}
func TestGistsService_Fork(t *testing.T) {
setup()
defer teardown()
@ -343,3 +378,8 @@ func TestGistsService_Fork(t *testing.T) {
t.Errorf("Gists.Fork returned %+v, want %+v", gist, want)
}
}
func TestGistsService_Fork_invalidID(t *testing.T) {
_, _, err := client.Gists.Fork("%")
testURLParseError(t, err)
}

+ 10
- 0
github/git_commits_test.go View File

@ -33,6 +33,11 @@ func TestGitService_GetCommit(t *testing.T) {
}
}
func TestGitService_GetCommit_invalidOwner(t *testing.T) {
_, _, err := client.Git.GetCommit("%", "%", "%")
testURLParseError(t, err)
}
func TestGitService_CreateCommit(t *testing.T) {
setup()
defer teardown()
@ -60,3 +65,8 @@ func TestGitService_CreateCommit(t *testing.T) {
t.Errorf("Git.CreateCommit returned %+v, want %+v", commit, want)
}
}
func TestGitService_CreateCommit_invalidOwner(t *testing.T) {
_, _, err := client.Git.CreateCommit("%", "%", nil)
testURLParseError(t, err)
}

+ 10
- 0
github/git_trees_test.go View File

@ -45,6 +45,11 @@ func TestGitService_GetTree(t *testing.T) {
}
}
func TestGitService_GetTree_invalidOwner(t *testing.T) {
_, _, err := client.Git.GetTree("%", "%", "%", false)
testURLParseError(t, err)
}
func TestGitService_CreateTree(t *testing.T) {
setup()
defer teardown()
@ -110,3 +115,8 @@ func TestGitService_CreateTree(t *testing.T) {
t.Errorf("Git.CreateTree returned %+v, want %+v", *tree, want)
}
}
func TestGitService_CreateTree_invalidOwner(t *testing.T) {
_, _, err := client.Git.CreateTree("%", "%", "", nil)
testURLParseError(t, err)
}

+ 12
- 0
github/github_test.go View File

@ -187,6 +187,18 @@ func TestResponse_populatePageValues_invalid(t *testing.T) {
if want, got := 0, response.LastPage; want != got {
t.Errorf("response.LastPage: %v, want %v", want, got)
}
// more invalid URLs
r = http.Response{
Header: http.Header{
"Link": {`<https://api.github.com/%?page=2>; rel="first"`},
},
}
response = newResponse(&r)
if want, got := 0, response.FirstPage; want != got {
t.Errorf("response.FirstPage: %v, want %v", want, got)
}
}
func TestDo(t *testing.T) {


+ 55
- 0
github/issues_labels_test.go View File

@ -33,6 +33,11 @@ func TestIssuesService_ListLabels(t *testing.T) {
}
}
func TestIssuesService_ListLabels_invalidOwner(t *testing.T) {
_, _, err := client.Issues.ListLabels("%", "%")
testURLParseError(t, err)
}
func TestIssuesService_GetLabel(t *testing.T) {
setup()
defer teardown()
@ -53,6 +58,11 @@ func TestIssuesService_GetLabel(t *testing.T) {
}
}
func TestIssuesService_GetLabel_invalidOwner(t *testing.T) {
_, _, err := client.Issues.GetLabel("%", "%", "%")
testURLParseError(t, err)
}
func TestIssuesService_CreateLabel(t *testing.T) {
setup()
defer teardown()
@ -82,6 +92,11 @@ func TestIssuesService_CreateLabel(t *testing.T) {
}
}
func TestIssuesService_CreateLabel_invalidOwner(t *testing.T) {
_, _, err := client.Issues.CreateLabel("%", "%", nil)
testURLParseError(t, err)
}
func TestIssuesService_EditLabel(t *testing.T) {
setup()
defer teardown()
@ -111,6 +126,11 @@ func TestIssuesService_EditLabel(t *testing.T) {
}
}
func TestIssuesService_EditLabel_invalidOwner(t *testing.T) {
_, _, err := client.Issues.EditLabel("%", "%", "%", nil)
testURLParseError(t, err)
}
func TestIssuesService_DeleteLabel(t *testing.T) {
setup()
defer teardown()
@ -125,6 +145,11 @@ func TestIssuesService_DeleteLabel(t *testing.T) {
}
}
func TestIssuesService_DeleteLabel_invalidOwner(t *testing.T) {
_, err := client.Issues.DeleteLabel("%", "%", "%")
testURLParseError(t, err)
}
func TestIssuesService_ListLabelsByIssue(t *testing.T) {
setup()
defer teardown()
@ -145,6 +170,11 @@ func TestIssuesService_ListLabelsByIssue(t *testing.T) {
}
}
func TestIssuesService_ListLabelsByIssue_invalidOwner(t *testing.T) {
_, _, err := client.Issues.ListLabelsByIssue("%", "%", 1)
testURLParseError(t, err)
}
func TestIssuesService_AddLabelsToIssue(t *testing.T) {
setup()
defer teardown()
@ -174,6 +204,11 @@ func TestIssuesService_AddLabelsToIssue(t *testing.T) {
}
}
func TestIssuesService_AddLabelsToIssue_invalidOwner(t *testing.T) {
_, _, err := client.Issues.AddLabelsToIssue("%", "%", 1, nil)
testURLParseError(t, err)
}
func TestIssuesService_RemoveLabelForIssue(t *testing.T) {
setup()
defer teardown()
@ -188,6 +223,11 @@ func TestIssuesService_RemoveLabelForIssue(t *testing.T) {
}
}
func TestIssuesService_RemoveLabelForIssue_invalidOwner(t *testing.T) {
_, err := client.Issues.RemoveLabelForIssue("%", "%", 1, "%")
testURLParseError(t, err)
}
func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) {
setup()
defer teardown()
@ -217,6 +257,11 @@ func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) {
}
}
func TestIssuesService_ReplaceLabelsForIssue_invalidOwner(t *testing.T) {
_, _, err := client.Issues.ReplaceLabelsForIssue("%", "%", 1, nil)
testURLParseError(t, err)
}
func TestIssuesService_RemoveLabelsForIssue(t *testing.T) {
setup()
defer teardown()
@ -231,6 +276,11 @@ func TestIssuesService_RemoveLabelsForIssue(t *testing.T) {
}
}
func TestIssuesService_RemoveLabelsForIssue_invalidOwner(t *testing.T) {
_, err := client.Issues.RemoveLabelsForIssue("%", "%", 1)
testURLParseError(t, err)
}
func TestIssuesService_ListLabelsForMilestone(t *testing.T) {
setup()
defer teardown()
@ -250,3 +300,8 @@ func TestIssuesService_ListLabelsForMilestone(t *testing.T) {
t.Errorf("Issues.ListLabelsForMilestone returned %+v, want %+v", labels, want)
}
}
func TestIssuesService_ListLabelsForMilestone_invalidOwner(t *testing.T) {
_, _, err := client.Issues.ListLabelsForMilestone("%", "%", 1)
testURLParseError(t, err)
}

+ 20
- 0
github/repos_collaborators_test.go View File

@ -32,6 +32,11 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) {
}
}
func TestRepositoriesService_ListCollaborators_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.ListCollaborators("%", "%")
testURLParseError(t, err)
}
func TestRepositoriesService_IsCollaborator_True(t *testing.T) {
setup()
defer teardown()
@ -70,6 +75,11 @@ func TestRepositoriesService_IsCollaborator_False(t *testing.T) {
}
}
func TestRepositoriesService_IsCollaborator_invalidUser(t *testing.T) {
_, _, err := client.Repositories.IsCollaborator("%", "%", "%")
testURLParseError(t, err)
}
func TestRepositoriesService_AddCollaborator(t *testing.T) {
setup()
defer teardown()
@ -85,6 +95,11 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) {
}
}
func TestRepositoriesService_AddCollaborator_invalidUser(t *testing.T) {
_, err := client.Repositories.AddCollaborator("%", "%", "%")
testURLParseError(t, err)
}
func TestRepositoriesService_RemoveCollaborator(t *testing.T) {
setup()
defer teardown()
@ -99,3 +114,8 @@ func TestRepositoriesService_RemoveCollaborator(t *testing.T) {
t.Errorf("Repositories.RemoveCollaborator returned error: %v", err)
}
}
func TestRepositoriesService_RemoveCollaborator_invalidUser(t *testing.T) {
_, err := client.Repositories.RemoveCollaborator("%", "%", "%")
testURLParseError(t, err)
}

+ 30
- 0
github/repos_comments_test.go View File

@ -33,6 +33,11 @@ func TestRepositoriesService_ListComments(t *testing.T) {
}
}
func TestRepositoriesService_ListComments_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.ListComments("%", "%")
testURLParseError(t, err)
}
func TestRepositoriesService_ListCommitComments(t *testing.T) {
setup()
defer teardown()
@ -53,6 +58,11 @@ func TestRepositoriesService_ListCommitComments(t *testing.T) {
}
}
func TestRepositoriesService_ListCommitComments_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.ListCommitComments("%", "%", "%")
testURLParseError(t, err)
}
func TestRepositoriesService_CreateComment(t *testing.T) {
setup()
defer teardown()
@ -82,6 +92,11 @@ func TestRepositoriesService_CreateComment(t *testing.T) {
}
}
func TestRepositoriesService_CreateComment_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.CreateComment("%", "%", "%", nil)
testURLParseError(t, err)
}
func TestRepositoriesService_GetComment(t *testing.T) {
setup()
defer teardown()
@ -102,6 +117,11 @@ func TestRepositoriesService_GetComment(t *testing.T) {
}
}
func TestRepositoriesService_GetComment_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.GetComment("%", "%", 1)
testURLParseError(t, err)
}
func TestRepositoriesService_UpdateComment(t *testing.T) {
setup()
defer teardown()
@ -131,6 +151,11 @@ func TestRepositoriesService_UpdateComment(t *testing.T) {
}
}
func TestRepositoriesService_UpdateComment_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.UpdateComment("%", "%", 1, nil)
testURLParseError(t, err)
}
func TestRepositoriesService_DeleteComment(t *testing.T) {
setup()
defer teardown()
@ -144,3 +169,8 @@ func TestRepositoriesService_DeleteComment(t *testing.T) {
t.Errorf("Repositories.DeleteComment returned error: %v", err)
}
}
func TestRepositoriesService_DeleteComment_invalidOwner(t *testing.T) {
_, err := client.Repositories.DeleteComment("%", "%", 1)
testURLParseError(t, err)
}

+ 30
- 0
github/repos_hooks_test.go View File

@ -42,6 +42,11 @@ func TestRepositoriesService_CreateHook(t *testing.T) {
}
}
func TestRepositoriesService_CreateHook_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.CreateHook("%", "%", nil)
testURLParseError(t, err)
}
func TestRepositoriesService_ListHooks(t *testing.T) {
setup()
defer teardown()
@ -65,6 +70,11 @@ func TestRepositoriesService_ListHooks(t *testing.T) {
}
}
func TestRepositoriesService_ListHooks_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.ListHooks("%", "%", nil)
testURLParseError(t, err)
}
func TestRepositoriesService_GetHook(t *testing.T) {
setup()
defer teardown()
@ -85,6 +95,11 @@ func TestRepositoriesService_GetHook(t *testing.T) {
}
}
func TestRepositoriesService_GetHook_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.GetHook("%", "%", 1)
testURLParseError(t, err)
}
func TestRepositoriesService_EditHook(t *testing.T) {
setup()
defer teardown()
@ -114,6 +129,11 @@ func TestRepositoriesService_EditHook(t *testing.T) {
}
}
func TestRepositoriesService_EditHook_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.EditHook("%", "%", 1, nil)
testURLParseError(t, err)
}
func TestRepositoriesService_DeleteHook(t *testing.T) {
setup()
defer teardown()
@ -128,6 +148,11 @@ func TestRepositoriesService_DeleteHook(t *testing.T) {
}
}
func TestRepositoriesService_DeleteHook_invalidOwner(t *testing.T) {
_, err := client.Repositories.DeleteHook("%", "%", 1)
testURLParseError(t, err)
}
func TestRepositoriesService_TestHook(t *testing.T) {
setup()
defer teardown()
@ -141,3 +166,8 @@ func TestRepositoriesService_TestHook(t *testing.T) {
t.Errorf("Repositories.TestHook returned error: %v", err)
}
}
func TestRepositoriesService_TestHook_invalidOwner(t *testing.T) {
_, err := client.Repositories.TestHook("%", "%", 1)
testURLParseError(t, err)
}

+ 20
- 0
github/repos_keys_test.go View File

@ -58,6 +58,11 @@ func TestRepositoriesService_GetKey(t *testing.T) {
}
}
func TestRepositoriesService_GetKey_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.GetKey("%", "%", 1)
testURLParseError(t, err)
}
func TestRepositoriesService_CreateKey(t *testing.T) {
setup()
defer teardown()
@ -87,6 +92,11 @@ func TestRepositoriesService_CreateKey(t *testing.T) {
}
}
func TestRepositoriesService_CreateKey_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.CreateKey("%", "%", nil)
testURLParseError(t, err)
}
func TestRepositoriesService_EditKey(t *testing.T) {
setup()
defer teardown()
@ -116,6 +126,11 @@ func TestRepositoriesService_EditKey(t *testing.T) {
}
}
func TestRepositoriesService_EditKey_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.EditKey("%", "%", 1, nil)
testURLParseError(t, err)
}
func TestRepositoriesService_DeleteKey(t *testing.T) {
setup()
defer teardown()
@ -129,3 +144,8 @@ func TestRepositoriesService_DeleteKey(t *testing.T) {
t.Errorf("Repositories.DeleteKey returned error: %v", err)
}
}
func TestRepositoriesService_DeleteKey_invalidOwner(t *testing.T) {
_, err := client.Repositories.DeleteKey("%", "%", 1)
testURLParseError(t, err)
}

+ 7
- 2
github/repos_test.go View File

@ -244,12 +244,12 @@ func TestRepositoriesService_ListLanguages(t *testing.T) {
setup()
defer teardown()
mux.HandleFunc("/repos/u/r/languages", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/o/r/languages", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"go":1}`)
})
languages, _, err := client.Repositories.ListLanguages("u", "r")
languages, _, err := client.Repositories.ListLanguages("o", "r")
if err != nil {
t.Errorf("Repositories.ListLanguages returned error: %v", err)
}
@ -259,3 +259,8 @@ func TestRepositoriesService_ListLanguages(t *testing.T) {
t.Errorf("Repositories.ListLanguages returned %+v, want %+v", languages, want)
}
}
func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) {
_, _, err := client.Repositories.ListLanguages("%", "%")
testURLParseError(t, err)
}

+ 5
- 0
github/search_test.go View File

@ -139,3 +139,8 @@ func TestSearchService_Code(t *testing.T) {
t.Errorf("Search.Code returned %+v, want %+v", result, want)
}
}
func TestSearchService_invalidQuery(t *testing.T) {
_, err := client.Search.search("%", "", nil, nil)
testURLParseError(t, err)
}

Loading…
Cancel
Save