From 49066fdbf661ff26d646b2da90979b63ad8f2410 Mon Sep 17 00:00:00 2001 From: Chris King Date: Sat, 28 Oct 2017 00:49:14 +0200 Subject: [PATCH 01/13] removes global test client and calls setup for each client test --- github/activity_events_test.go | 38 +++++++--- github/activity_notifications_test.go | 18 ++--- github/activity_star_test.go | 26 +++++-- github/activity_test.go | 2 +- github/activity_watching_test.go | 16 ++--- github/admin_test.go | 4 +- github/apps_installation_test.go | 6 +- github/apps_test.go | 2 +- github/authorizations_test.go | 32 ++++----- github/gists_comments_test.go | 25 +++++-- github/gists_test.go | 61 +++++++++++----- github/git_blobs_test.go | 10 ++- github/git_commits_test.go | 10 ++- github/git_refs_test.go | 20 +++--- github/git_tags_test.go | 4 +- github/git_trees_test.go | 12 +++- github/github_test.go | 38 +++++----- github/gitignore_test.go | 7 +- github/issues_assignees_test.go | 18 +++-- github/issues_comments_test.go | 27 ++++++-- github/issues_events_test.go | 6 +- github/issues_labels_test.go | 55 ++++++++++++--- github/issues_milestones_test.go | 25 +++++-- github/issues_test.go | 33 ++++++--- github/issues_timeline_test.go | 2 +- github/licenses_test.go | 7 +- github/migrations_source_import_test.go | 16 ++--- github/migrations_test.go | 12 ++-- github/misc_test.go | 16 ++--- github/orgs_hooks_test.go | 22 ++++-- github/orgs_members_test.go | 44 +++++++----- github/orgs_outside_collaborators_test.go | 5 +- github/orgs_projects_test.go | 4 +- github/orgs_teams_test.go | 70 ++++++++++++------- github/orgs_test.go | 21 ++++-- github/orgs_users_blocking_test.go | 8 +-- github/projects_test.go | 30 ++++---- github/pulls_comments_test.go | 27 ++++++-- github/pulls_reviewers_test.go | 8 +-- github/pulls_reviews_test.go | 37 +++++++--- github/pulls_test.go | 40 +++++++---- github/reactions_test.go | 18 ++--- github/repos_collaborators_test.go | 26 +++++-- github/repos_comments_test.go | 30 ++++++-- github/repos_commits_test.go | 8 +-- github/repos_community_health_test.go | 2 +- github/repos_contents_test.go | 26 +++---- github/repos_deployments_test.go | 12 ++-- github/repos_forks_test.go | 10 ++- github/repos_hooks_test.go | 32 +++++++-- github/repos_invitations_test.go | 6 +- github/repos_keys_test.go | 25 +++++-- github/repos_merging_test.go | 2 +- github/repos_pages_test.go | 12 ++-- github/repos_projects_test.go | 4 +- github/repos_releases_test.go | 30 ++++---- github/repos_stats_test.go | 10 +-- github/repos_statuses_test.go | 12 +++- github/repos_test.go | 84 ++++++++++++++--------- github/repos_traffic_test.go | 8 +-- github/search_test.go | 14 ++-- github/users_administration_test.go | 8 +-- github/users_blocking_test.go | 8 +-- github/users_emails_test.go | 6 +- github/users_followers_test.go | 35 +++++++--- github/users_gpg_keys_test.go | 13 ++-- github/users_keys_test.go | 13 ++-- github/users_test.go | 21 +++--- 68 files changed, 869 insertions(+), 470 deletions(-) diff --git a/github/activity_events_test.go b/github/activity_events_test.go index 2b59d11be8e..bc147835d9a 100644 --- a/github/activity_events_test.go +++ b/github/activity_events_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListEvents(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestActivityService_ListEvents(t *testing.T) { } func TestActivityService_ListRepositoryEvents(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/events", func(w http.ResponseWriter, r *http.Request) { @@ -63,12 +63,15 @@ func TestActivityService_ListRepositoryEvents(t *testing.T) { } func TestActivityService_ListRepositoryEvents_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Activity.ListRepositoryEvents(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestActivityService_ListIssueEventsForRepository(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events", func(w http.ResponseWriter, r *http.Request) { @@ -92,12 +95,15 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) { } func TestActivityService_ListIssueEventsForRepository_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Activity.ListIssueEventsForRepository(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestActivityService_ListEventsForRepoNetwork(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/networks/o/r/events", func(w http.ResponseWriter, r *http.Request) { @@ -121,12 +127,15 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) { } func TestActivityService_ListEventsForRepoNetwork_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Activity.ListEventsForRepoNetwork(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestActivityService_ListEventsForOrganization(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/events", func(w http.ResponseWriter, r *http.Request) { @@ -150,12 +159,15 @@ func TestActivityService_ListEventsForOrganization(t *testing.T) { } func TestActivityService_ListEventsForOrganization_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Activity.ListEventsForOrganization(context.Background(), "%", nil) testURLParseError(t, err) } func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events", func(w http.ResponseWriter, r *http.Request) { @@ -179,7 +191,7 @@ func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) { } func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events/public", func(w http.ResponseWriter, r *http.Request) { @@ -199,12 +211,15 @@ func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) { } func TestActivityService_ListEventsPerformedByUser_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Activity.ListEventsPerformedByUser(context.Background(), "%", false, nil) testURLParseError(t, err) } func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/received_events", func(w http.ResponseWriter, r *http.Request) { @@ -228,7 +243,7 @@ func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) { } func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/received_events/public", func(w http.ResponseWriter, r *http.Request) { @@ -248,12 +263,15 @@ func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) { } func TestActivityService_ListEventsReceivedByUser_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Activity.ListEventsReceivedByUser(context.Background(), "%", false, nil) testURLParseError(t, err) } func TestActivityService_ListUserEventsForOrganization(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events/orgs/o", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index cab8f94da8d..ed04901aff5 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -16,7 +16,7 @@ import ( ) func TestActivityService_ListNotification(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestActivityService_ListNotification(t *testing.T) { } func TestActivityService_ListRepositoryNotification(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestActivityService_ListRepositoryNotification(t *testing.T) { } func TestActivityService_MarkNotificationsRead(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -87,7 +87,7 @@ func TestActivityService_MarkNotificationsRead(t *testing.T) { } func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { } func TestActivityService_GetThread(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestActivityService_GetThread(t *testing.T) { } func TestActivityService_MarkThreadRead(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) { @@ -140,7 +140,7 @@ func TestActivityService_MarkThreadRead(t *testing.T) { } func TestActivityService_GetThreadSubscription(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -160,7 +160,7 @@ func TestActivityService_GetThreadSubscription(t *testing.T) { } func TestActivityService_SetThreadSubscription(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Subscription{Subscribed: Bool(true)} @@ -189,7 +189,7 @@ func TestActivityService_SetThreadSubscription(t *testing.T) { } func TestActivityService_DeleteThreadSubscription(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 542bfc66b4b..cfbac41ff1a 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListStargazers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stargazers", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestActivityService_ListStargazers(t *testing.T) { } func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred", func(w http.ResponseWriter, r *http.Request) { @@ -61,7 +61,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { } func TestActivityService_ListStarred_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/starred", func(w http.ResponseWriter, r *http.Request) { @@ -88,12 +88,15 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) { } func TestActivityService_ListStarred_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Activity.ListStarred(context.Background(), "%", nil) testURLParseError(t, err) } func TestActivityService_IsStarred_hasStar(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -111,7 +114,7 @@ func TestActivityService_IsStarred_hasStar(t *testing.T) { } func TestActivityService_IsStarred_noStar(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -129,12 +132,15 @@ func TestActivityService_IsStarred_noStar(t *testing.T) { } func TestActivityService_IsStarred_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Activity.IsStarred(context.Background(), "%", "%") testURLParseError(t, err) } func TestActivityService_Star(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -148,12 +154,15 @@ func TestActivityService_Star(t *testing.T) { } func TestActivityService_Star_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Activity.Star(context.Background(), "%", "%") testURLParseError(t, err) } func TestActivityService_Unstar(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -167,6 +176,9 @@ func TestActivityService_Unstar(t *testing.T) { } func TestActivityService_Unstar_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Activity.Unstar(context.Background(), "%", "%") testURLParseError(t, err) } diff --git a/github/activity_test.go b/github/activity_test.go index 98567a254b6..bf240984b45 100644 --- a/github/activity_test.go +++ b/github/activity_test.go @@ -13,7 +13,7 @@ import ( ) func TestActivityService_List(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/feeds", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index d765f67e9e0..db2596d15fb 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListWatchers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscribers", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestActivityService_ListWatchers(t *testing.T) { } func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/subscriptions", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { } func TestActivityService_ListWatched_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/subscriptions", func(w http.ResponseWriter, r *http.Request) { @@ -85,7 +85,7 @@ func TestActivityService_ListWatched_specifiedUser(t *testing.T) { } func TestActivityService_GetRepositorySubscription_true(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestActivityService_GetRepositorySubscription_true(t *testing.T) { } func TestActivityService_GetRepositorySubscription_false(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestActivityService_GetRepositorySubscription_false(t *testing.T) { } func TestActivityService_GetRepositorySubscription_error(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -140,7 +140,7 @@ func TestActivityService_GetRepositorySubscription_error(t *testing.T) { } func TestActivityService_SetRepositorySubscription(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Subscription{Subscribed: Bool(true)} @@ -169,7 +169,7 @@ func TestActivityService_SetRepositorySubscription(t *testing.T) { } func TestActivityService_DeleteRepositorySubscription(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/admin_test.go b/github/admin_test.go index 32a870eb407..aeb40830321 100644 --- a/github/admin_test.go +++ b/github/admin_test.go @@ -15,7 +15,7 @@ import ( ) func TestAdminService_UpdateUserLDAPMapping(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &UserLDAPMapping{ @@ -48,7 +48,7 @@ func TestAdminService_UpdateUserLDAPMapping(t *testing.T) { } func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &TeamLDAPMapping{ diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index 69598cfe5f8..1dcbb20c933 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -14,7 +14,7 @@ import ( ) func TestAppsService_ListRepos(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/installation/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestAppsService_ListRepos(t *testing.T) { } func TestAppsService_AddRepository(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/apps/installations/1/repositories/1", func(w http.ResponseWriter, r *http.Request) { @@ -60,7 +60,7 @@ func TestAppsService_AddRepository(t *testing.T) { } func TestAppsService_RemoveRepository(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/apps/installations/1/repositories/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/apps_test.go b/github/apps_test.go index f847b84271c..a7b858c698b 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -14,7 +14,7 @@ import ( ) func TestAppsService_ListInstallations(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/app/installations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/authorizations_test.go b/github/authorizations_test.go index 61bf21252a4..1a33bb2e0af 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -15,7 +15,7 @@ import ( ) func TestAuthorizationsService_List(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/authorizations", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestAuthorizationsService_List(t *testing.T) { } func TestAuthorizationsService_Get(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestAuthorizationsService_Get(t *testing.T) { } func TestAuthorizationsService_Create(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -88,7 +88,7 @@ func TestAuthorizationsService_Create(t *testing.T) { } func TestAuthorizationsService_GetOrCreateForApp(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -119,7 +119,7 @@ func TestAuthorizationsService_GetOrCreateForApp(t *testing.T) { } func TestAuthorizationsService_GetOrCreateForApp_Fingerprint(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -151,7 +151,7 @@ func TestAuthorizationsService_GetOrCreateForApp_Fingerprint(t *testing.T) { } func TestAuthorizationsService_Edit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &AuthorizationUpdateRequest{ @@ -182,7 +182,7 @@ func TestAuthorizationsService_Edit(t *testing.T) { } func TestAuthorizationsService_Delete(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -197,7 +197,7 @@ func TestAuthorizationsService_Delete(t *testing.T) { } func TestAuthorizationsService_Check(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -217,7 +217,7 @@ func TestAuthorizationsService_Check(t *testing.T) { } func TestAuthorizationsService_Reset(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -237,7 +237,7 @@ func TestAuthorizationsService_Reset(t *testing.T) { } func TestAuthorizationsService_Revoke(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -252,7 +252,7 @@ func TestAuthorizationsService_Revoke(t *testing.T) { } func TestListGrants(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) { @@ -272,7 +272,7 @@ func TestListGrants(t *testing.T) { } func TestListGrants_withOptions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) { @@ -290,7 +290,7 @@ func TestListGrants_withOptions(t *testing.T) { } func TestGetGrant(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) { @@ -310,7 +310,7 @@ func TestGetGrant(t *testing.T) { } func TestDeleteGrant(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) { @@ -324,7 +324,7 @@ func TestDeleteGrant(t *testing.T) { } func TestAuthorizationsService_CreateImpersonation(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) { @@ -345,7 +345,7 @@ func TestAuthorizationsService_CreateImpersonation(t *testing.T) { } func TestAuthorizationsService_DeleteImpersonation(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/gists_comments_test.go b/github/gists_comments_test.go index 4b6841363ea..05857dc60dc 100644 --- a/github/gists_comments_test.go +++ b/github/gists_comments_test.go @@ -15,7 +15,7 @@ import ( ) func TestGistsService_ListComments(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -37,12 +37,15 @@ func TestGistsService_ListComments(t *testing.T) { } func TestGistsService_ListComments_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.ListComments(context.Background(), "%", nil) testURLParseError(t, err) } func TestGistsService_GetComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) { @@ -62,12 +65,15 @@ func TestGistsService_GetComment(t *testing.T) { } func TestGistsService_GetComment_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.GetComment(context.Background(), "%", 1) testURLParseError(t, err) } func TestGistsService_CreateComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &GistComment{ID: Int(1), Body: String("b")} @@ -96,12 +102,15 @@ func TestGistsService_CreateComment(t *testing.T) { } func TestGistsService_CreateComment_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.CreateComment(context.Background(), "%", nil) testURLParseError(t, err) } func TestGistsService_EditComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &GistComment{ID: Int(1), Body: String("b")} @@ -130,12 +139,15 @@ func TestGistsService_EditComment(t *testing.T) { } func TestGistsService_EditComment_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.EditComment(context.Background(), "%", 1, nil) testURLParseError(t, err) } func TestGistsService_DeleteComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) { @@ -149,6 +161,9 @@ func TestGistsService_DeleteComment(t *testing.T) { } func TestGistsService_DeleteComment_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Gists.DeleteComment(context.Background(), "%", 1) testURLParseError(t, err) } diff --git a/github/gists_test.go b/github/gists_test.go index 6065f277d8a..cb2eee25fef 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -16,7 +16,7 @@ import ( ) func TestGistsService_List_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -42,7 +42,7 @@ func TestGistsService_List_specifiedUser(t *testing.T) { } func TestGistsService_List_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists", func(w http.ResponseWriter, r *http.Request) { @@ -62,12 +62,15 @@ func TestGistsService_List_authenticatedUser(t *testing.T) { } func TestGistsService_List_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.List(context.Background(), "%", nil) testURLParseError(t, err) } func TestGistsService_ListAll(t *testing.T) { - setup() + client, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -93,7 +96,7 @@ func TestGistsService_ListAll(t *testing.T) { } func TestGistsService_ListStarred(t *testing.T) { - setup() + client, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -119,7 +122,7 @@ func TestGistsService_ListStarred(t *testing.T) { } func TestGistsService_Get(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) { @@ -139,12 +142,15 @@ func TestGistsService_Get(t *testing.T) { } func TestGistsService_Get_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.Get(context.Background(), "%") testURLParseError(t, err) } func TestGistsService_GetRevision(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/s", func(w http.ResponseWriter, r *http.Request) { @@ -164,12 +170,15 @@ func TestGistsService_GetRevision(t *testing.T) { } func TestGistsService_GetRevision_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.GetRevision(context.Background(), "%", "%") testURLParseError(t, err) } func TestGistsService_Create(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Gist{ @@ -222,7 +231,7 @@ func TestGistsService_Create(t *testing.T) { } func TestGistsService_Edit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Gist{ @@ -278,12 +287,15 @@ func TestGistsService_Edit(t *testing.T) { } func TestGistsService_Edit_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.Edit(context.Background(), "%", nil) testURLParseError(t, err) } func TestGistsService_ListCommits(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -330,7 +342,7 @@ func TestGistsService_ListCommits(t *testing.T) { } func TestGistsService_ListCommits_withOptions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -348,7 +360,7 @@ func TestGistsService_ListCommits_withOptions(t *testing.T) { } func TestGistsService_Delete(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) { @@ -362,12 +374,15 @@ func TestGistsService_Delete(t *testing.T) { } func TestGistsService_Delete_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Gists.Delete(context.Background(), "%") testURLParseError(t, err) } func TestGistsService_Star(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -381,12 +396,15 @@ func TestGistsService_Star(t *testing.T) { } func TestGistsService_Star_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Gists.Star(context.Background(), "%") testURLParseError(t, err) } func TestGistsService_Unstar(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -400,12 +418,15 @@ func TestGistsService_Unstar(t *testing.T) { } func TestGistsService_Unstar_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Gists.Unstar(context.Background(), "%") testURLParseError(t, err) } func TestGistsService_IsStarred_hasStar(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -423,7 +444,7 @@ func TestGistsService_IsStarred_hasStar(t *testing.T) { } func TestGistsService_IsStarred_noStar(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -441,12 +462,15 @@ func TestGistsService_IsStarred_noStar(t *testing.T) { } func TestGistsService_IsStarred_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.IsStarred(context.Background(), "%") testURLParseError(t, err) } func TestGistsService_Fork(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) { @@ -466,7 +490,7 @@ func TestGistsService_Fork(t *testing.T) { } func TestGistsService_ListForks(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) { @@ -502,6 +526,9 @@ func TestGistsService_ListForks(t *testing.T) { } func TestGistsService_Fork_invalidID(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gists.Fork(context.Background(), "%") testURLParseError(t, err) } diff --git a/github/git_blobs_test.go b/github/git_blobs_test.go index 00861bb9a64..6e30cf09a0f 100644 --- a/github/git_blobs_test.go +++ b/github/git_blobs_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetBlob(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/blobs/s", func(w http.ResponseWriter, r *http.Request) { @@ -44,12 +44,15 @@ func TestGitService_GetBlob(t *testing.T) { } func TestGitService_GetBlob_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Git.GetBlob(context.Background(), "%", "%", "%") testURLParseError(t, err) } func TestGitService_CreateBlob(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Blob{ @@ -93,6 +96,9 @@ func TestGitService_CreateBlob(t *testing.T) { } func TestGitService_CreateBlob_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Git.CreateBlob(context.Background(), "%", "%", &Blob{}) testURLParseError(t, err) } diff --git a/github/git_commits_test.go b/github/git_commits_test.go index cd392329ea2..c70a05c0f6b 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetCommit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/commits/s", func(w http.ResponseWriter, r *http.Request) { @@ -36,12 +36,15 @@ func TestGitService_GetCommit(t *testing.T) { } func TestGitService_GetCommit_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Git.GetCommit(context.Background(), "%", "%", "%") testURLParseError(t, err) } func TestGitService_CreateCommit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Commit{ @@ -79,6 +82,9 @@ func TestGitService_CreateCommit(t *testing.T) { } func TestGitService_CreateCommit_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Git.CreateCommit(context.Background(), "%", "%", &Commit{}) testURLParseError(t, err) } diff --git a/github/git_refs_test.go b/github/git_refs_test.go index 62025bf4446..55aa659e356 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetRef_singleRef(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestGitService_GetRef_singleRef(t *testing.T) { } func TestGitService_GetRef_multipleRefs(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -95,7 +95,7 @@ func TestGitService_GetRef_multipleRefs(t *testing.T) { } func TestGitService_GetRefs_singleRef(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -138,7 +138,7 @@ func TestGitService_GetRefs_singleRef(t *testing.T) { } func TestGitService_GetRefs_multipleRefs(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -188,7 +188,7 @@ func TestGitService_GetRefs_multipleRefs(t *testing.T) { // TestGitService_GetRefs_noRefs tests for behaviour resulting from an unexpected GH response. This should never actually happen. func TestGitService_GetRefs_noRefs(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -205,7 +205,7 @@ func TestGitService_GetRefs_noRefs(t *testing.T) { } func TestGitService_ListRefs(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs", func(w http.ResponseWriter, r *http.Request) { @@ -264,7 +264,7 @@ func TestGitService_ListRefs(t *testing.T) { } func TestGitService_ListRefs_options(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/t", func(w http.ResponseWriter, r *http.Request) { @@ -286,7 +286,7 @@ func TestGitService_ListRefs_options(t *testing.T) { } func TestGitService_CreateRef(t *testing.T) { - setup() + client, teardown := setup() defer teardown() args := &createRefRequest{ @@ -350,7 +350,7 @@ func TestGitService_CreateRef(t *testing.T) { } func TestGitService_UpdateRef(t *testing.T) { - setup() + client, teardown := setup() defer teardown() args := &updateRefRequest{ @@ -410,7 +410,7 @@ func TestGitService_UpdateRef(t *testing.T) { } func TestGitService_DeleteRef(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/git_tags_test.go b/github/git_tags_test.go index 7031fe8a4d3..e9c06efb2a0 100644 --- a/github/git_tags_test.go +++ b/github/git_tags_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetTag(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/tags/s", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestGitService_GetTag(t *testing.T) { } func TestGitService_CreateTag(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &createTagRequest{Tag: String("t"), Object: String("s")} diff --git a/github/git_trees_test.go b/github/git_trees_test.go index 29728eee381..492359a0c26 100644 --- a/github/git_trees_test.go +++ b/github/git_trees_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetTree(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/trees/s", func(w http.ResponseWriter, r *http.Request) { @@ -47,12 +47,15 @@ func TestGitService_GetTree(t *testing.T) { } func TestGitService_GetTree_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Git.GetTree(context.Background(), "%", "%", "%", false) testURLParseError(t, err) } func TestGitService_CreateTree(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := []TreeEntry{ @@ -118,7 +121,7 @@ func TestGitService_CreateTree(t *testing.T) { } func TestGitService_CreateTree_Content(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := []TreeEntry{ @@ -186,6 +189,9 @@ func TestGitService_CreateTree_Content(t *testing.T) { } func TestGitService_CreateTree_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Git.CreateTree(context.Background(), "%", "%", "", nil) testURLParseError(t, err) } diff --git a/github/github_test.go b/github/github_test.go index aff436a6d59..2d9390427bd 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -26,9 +26,6 @@ var ( // mux is the HTTP request multiplexer used with the test server. mux *http.ServeMux - // client is the GitHub client being tested. - client *Client - // server is a test HTTP server used to provide mock API responses. server *httptest.Server ) @@ -42,7 +39,7 @@ const ( // setup sets up a test HTTP server along with a github.Client that is // configured to talk to that test server. Tests should register handlers on // mux which provide mock responses for the API method being tested. -func setup() { +func setup() (*Client, func()) { // test server mux = http.NewServeMux() @@ -64,15 +61,12 @@ func setup() { server = httptest.NewServer(apiHandler) // github client configured to use test server - client = NewClient(nil) + client := NewClient(nil) url, _ := url.Parse(server.URL + baseURLPath + "/") client.BaseURL = url client.UploadURL = url -} -// teardown closes the test HTTP server. -func teardown() { - server.Close() + return client, server.Close } // openTestFile creates a new file with the given name and content for testing. @@ -382,7 +376,7 @@ func TestResponse_populatePageValues_invalid(t *testing.T) { } func TestDo(t *testing.T) { - setup() + client, teardown := setup() defer teardown() type foo struct { @@ -407,7 +401,7 @@ func TestDo(t *testing.T) { } func TestDo_httpError(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -429,7 +423,7 @@ func TestDo_httpError(t *testing.T) { // function. A redirect loop is pretty unlikely to occur within the GitHub // API, but does allow us to exercise the right code path. func TestDo_redirectLoop(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -470,7 +464,7 @@ func TestDo_sanitizeURL(t *testing.T) { } func TestDo_rateLimit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -498,7 +492,7 @@ func TestDo_rateLimit(t *testing.T) { // ensure rate limit is still parsed, even for error responses func TestDo_rateLimit_errorResponse(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -530,7 +524,7 @@ func TestDo_rateLimit_errorResponse(t *testing.T) { // Ensure *RateLimitError is returned when API rate limit is exceeded. func TestDo_rateLimit_rateLimitError(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -569,7 +563,7 @@ func TestDo_rateLimit_rateLimitError(t *testing.T) { // Ensure a network call is not made when it's known that API rate limit is still exceeded. func TestDo_rateLimit_noNetworkCall(t *testing.T) { - setup() + client, teardown := setup() defer teardown() reset := time.Now().UTC().Add(time.Minute).Round(time.Second) // Rate reset is a minute from now, with 1 second precision. @@ -624,7 +618,7 @@ func TestDo_rateLimit_noNetworkCall(t *testing.T) { // Ensure *AbuseRateLimitError is returned when the response indicates that // the client has triggered an abuse detection mechanism. func TestDo_rateLimit_abuseRateLimitError(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -655,7 +649,7 @@ func TestDo_rateLimit_abuseRateLimitError(t *testing.T) { // Ensure *AbuseRateLimitError.RetryAfter is parsed correctly. func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -687,7 +681,7 @@ func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { } func TestDo_noContent(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -826,7 +820,7 @@ func TestError_Error(t *testing.T) { } func TestRateLimits(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) { @@ -869,7 +863,7 @@ func TestRateLimits(t *testing.T) { } func TestUnauthenticatedRateLimitedTransport(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -935,7 +929,7 @@ func TestUnauthenticatedRateLimitedTransport_transport(t *testing.T) { } func TestBasicAuthTransport(t *testing.T) { - setup() + client, teardown := setup() defer teardown() username, password, otp := "u", "p", "123456" diff --git a/github/gitignore_test.go b/github/gitignore_test.go index e5a62643b5d..07a2e301101 100644 --- a/github/gitignore_test.go +++ b/github/gitignore_test.go @@ -14,7 +14,7 @@ import ( ) func TestGitignoresService_List(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gitignore/templates", func(w http.ResponseWriter, r *http.Request) { @@ -34,7 +34,7 @@ func TestGitignoresService_List(t *testing.T) { } func TestGitignoresService_Get(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/gitignore/templates/name", func(w http.ResponseWriter, r *http.Request) { @@ -54,6 +54,9 @@ func TestGitignoresService_Get(t *testing.T) { } func TestGitignoresService_Get_invalidTemplate(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Gitignores.Get(context.Background(), "%") testURLParseError(t, err) } diff --git a/github/issues_assignees_test.go b/github/issues_assignees_test.go index d88a7888a4e..474d98fa0c9 100644 --- a/github/issues_assignees_test.go +++ b/github/issues_assignees_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListAssignees(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees", func(w http.ResponseWriter, r *http.Request) { @@ -37,12 +37,15 @@ func TestIssuesService_ListAssignees(t *testing.T) { } func TestIssuesService_ListAssignees_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ListAssignees(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestIssuesService_IsAssignee_true(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -59,7 +62,7 @@ func TestIssuesService_IsAssignee_true(t *testing.T) { } func TestIssuesService_IsAssignee_false(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -77,7 +80,7 @@ func TestIssuesService_IsAssignee_false(t *testing.T) { } func TestIssuesService_IsAssignee_error(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -95,12 +98,15 @@ func TestIssuesService_IsAssignee_error(t *testing.T) { } func TestIssuesService_IsAssignee_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.IsAssignee(context.Background(), "%", "r", "u") testURLParseError(t, err) } func TestIssuesService_AddAssignees(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) { @@ -129,7 +135,7 @@ func TestIssuesService_AddAssignees(t *testing.T) { } func TestIssuesService_RemoveAssignees(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index 78c486362f4..7661e88e9dc 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -16,7 +16,7 @@ import ( ) func TestIssuesService_ListComments_allIssues(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) { } func TestIssuesService_ListComments_specificIssue(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -70,12 +70,15 @@ func TestIssuesService_ListComments_specificIssue(t *testing.T) { } func TestIssuesService_ListComments_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ListComments(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestIssuesService_GetComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -96,12 +99,15 @@ func TestIssuesService_GetComment(t *testing.T) { } func TestIssuesService_GetComment_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.GetComment(context.Background(), "%", "r", 1) testURLParseError(t, err) } func TestIssuesService_CreateComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &IssueComment{Body: String("b")} @@ -130,12 +136,15 @@ func TestIssuesService_CreateComment(t *testing.T) { } func TestIssuesService_CreateComment_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.CreateComment(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestIssuesService_EditComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &IssueComment{Body: String("b")} @@ -164,12 +173,15 @@ func TestIssuesService_EditComment(t *testing.T) { } func TestIssuesService_EditComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.EditComment(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestIssuesService_DeleteComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -183,6 +195,9 @@ func TestIssuesService_DeleteComment(t *testing.T) { } func TestIssuesService_DeleteComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Issues.DeleteComment(context.Background(), "%", "r", 1) testURLParseError(t, err) } diff --git a/github/issues_events_test.go b/github/issues_events_test.go index d85b6223eaa..1acc5eed252 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -14,7 +14,7 @@ import ( ) func TestIssuesService_ListIssueEvents(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/events", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestIssuesService_ListIssueEvents(t *testing.T) { } func TestIssuesService_ListRepositoryEvents(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events", func(w http.ResponseWriter, r *http.Request) { @@ -64,7 +64,7 @@ func TestIssuesService_ListRepositoryEvents(t *testing.T) { } func TestIssuesService_GetEvent(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_labels_test.go b/github/issues_labels_test.go index 5380427a1e6..4bb84f297ec 100644 --- a/github/issues_labels_test.go +++ b/github/issues_labels_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListLabels(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels", func(w http.ResponseWriter, r *http.Request) { @@ -37,12 +37,15 @@ func TestIssuesService_ListLabels(t *testing.T) { } func TestIssuesService_ListLabels_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ListLabels(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestIssuesService_GetLabel(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) { @@ -62,12 +65,15 @@ func TestIssuesService_GetLabel(t *testing.T) { } func TestIssuesService_GetLabel_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.GetLabel(context.Background(), "%", "%", "%") testURLParseError(t, err) } func TestIssuesService_CreateLabel(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Label{Name: String("n")} @@ -96,12 +102,15 @@ func TestIssuesService_CreateLabel(t *testing.T) { } func TestIssuesService_CreateLabel_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.CreateLabel(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestIssuesService_EditLabel(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Label{Name: String("z")} @@ -130,12 +139,15 @@ func TestIssuesService_EditLabel(t *testing.T) { } func TestIssuesService_EditLabel_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.EditLabel(context.Background(), "%", "%", "%", nil) testURLParseError(t, err) } func TestIssuesService_DeleteLabel(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) { @@ -149,12 +161,15 @@ func TestIssuesService_DeleteLabel(t *testing.T) { } func TestIssuesService_DeleteLabel_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Issues.DeleteLabel(context.Background(), "%", "%", "%") testURLParseError(t, err) } func TestIssuesService_ListLabelsByIssue(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -179,12 +194,15 @@ func TestIssuesService_ListLabelsByIssue(t *testing.T) { } func TestIssuesService_ListLabelsByIssue_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ListLabelsByIssue(context.Background(), "%", "%", 1, nil) testURLParseError(t, err) } func TestIssuesService_AddLabelsToIssue(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := []string{"a", "b"} @@ -213,12 +231,15 @@ func TestIssuesService_AddLabelsToIssue(t *testing.T) { } func TestIssuesService_AddLabelsToIssue_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.AddLabelsToIssue(context.Background(), "%", "%", 1, nil) testURLParseError(t, err) } func TestIssuesService_RemoveLabelForIssue(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels/l", func(w http.ResponseWriter, r *http.Request) { @@ -232,12 +253,15 @@ func TestIssuesService_RemoveLabelForIssue(t *testing.T) { } func TestIssuesService_RemoveLabelForIssue_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Issues.RemoveLabelForIssue(context.Background(), "%", "%", 1, "%") testURLParseError(t, err) } func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := []string{"a", "b"} @@ -266,12 +290,15 @@ func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) { } func TestIssuesService_ReplaceLabelsForIssue_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ReplaceLabelsForIssue(context.Background(), "%", "%", 1, nil) testURLParseError(t, err) } func TestIssuesService_RemoveLabelsForIssue(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -285,12 +312,15 @@ func TestIssuesService_RemoveLabelsForIssue(t *testing.T) { } func TestIssuesService_RemoveLabelsForIssue_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Issues.RemoveLabelsForIssue(context.Background(), "%", "%", 1) testURLParseError(t, err) } func TestIssuesService_ListLabelsForMilestone(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -312,6 +342,9 @@ func TestIssuesService_ListLabelsForMilestone(t *testing.T) { } func TestIssuesService_ListLabelsForMilestone_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ListLabelsForMilestone(context.Background(), "%", "%", 1, nil) testURLParseError(t, err) } diff --git a/github/issues_milestones_test.go b/github/issues_milestones_test.go index befa1b48727..9145f96b11d 100644 --- a/github/issues_milestones_test.go +++ b/github/issues_milestones_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListMilestones(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones", func(w http.ResponseWriter, r *http.Request) { @@ -42,12 +42,15 @@ func TestIssuesService_ListMilestones(t *testing.T) { } func TestIssuesService_ListMilestones_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ListMilestones(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestIssuesService_GetMilestone(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) { @@ -67,12 +70,15 @@ func TestIssuesService_GetMilestone(t *testing.T) { } func TestIssuesService_GetMilestone_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.GetMilestone(context.Background(), "%", "r", 1) testURLParseError(t, err) } func TestIssuesService_CreateMilestone(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Milestone{Title: String("t")} @@ -101,12 +107,15 @@ func TestIssuesService_CreateMilestone(t *testing.T) { } func TestIssuesService_CreateMilestone_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.CreateMilestone(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestIssuesService_EditMilestone(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Milestone{Title: String("t")} @@ -135,12 +144,15 @@ func TestIssuesService_EditMilestone(t *testing.T) { } func TestIssuesService_EditMilestone_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.EditMilestone(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestIssuesService_DeleteMilestone(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) { @@ -154,6 +166,9 @@ func TestIssuesService_DeleteMilestone(t *testing.T) { } func TestIssuesService_DeleteMilestone_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Issues.DeleteMilestone(context.Background(), "%", "r", 1) testURLParseError(t, err) } diff --git a/github/issues_test.go b/github/issues_test.go index da60740fb75..06ce91c9806 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -16,7 +16,7 @@ import ( ) func TestIssuesService_List_all(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/issues", func(w http.ResponseWriter, r *http.Request) { @@ -52,7 +52,7 @@ func TestIssuesService_List_all(t *testing.T) { } func TestIssuesService_List_owned(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/issues", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestIssuesService_List_owned(t *testing.T) { } func TestIssuesService_ListByOrg(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/issues", func(w http.ResponseWriter, r *http.Request) { @@ -94,12 +94,15 @@ func TestIssuesService_ListByOrg(t *testing.T) { } func TestIssuesService_ListByOrg_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ListByOrg(context.Background(), "%", nil) testURLParseError(t, err) } func TestIssuesService_ListByRepo(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues", func(w http.ResponseWriter, r *http.Request) { @@ -136,12 +139,15 @@ func TestIssuesService_ListByRepo(t *testing.T) { } func TestIssuesService_ListByRepo_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.ListByRepo(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestIssuesService_Get(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1", func(w http.ResponseWriter, r *http.Request) { @@ -169,12 +175,15 @@ func TestIssuesService_Get(t *testing.T) { } func TestIssuesService_Get_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.Get(context.Background(), "%", "r", 1) testURLParseError(t, err) } func TestIssuesService_Create(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &IssueRequest{ @@ -208,12 +217,15 @@ func TestIssuesService_Create(t *testing.T) { } func TestIssuesService_Create_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.Create(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestIssuesService_Edit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &IssueRequest{Title: String("t")} @@ -242,12 +254,15 @@ func TestIssuesService_Edit(t *testing.T) { } func TestIssuesService_Edit_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Issues.Edit(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestIssuesService_Lock(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) { @@ -262,7 +277,7 @@ func TestIssuesService_Lock(t *testing.T) { } func TestIssuesService_Unlock(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index 2fd22109b06..cfb0ba1be3f 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -14,7 +14,7 @@ import ( ) func TestIssuesService_ListIssueTimeline(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/timeline", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/licenses_test.go b/github/licenses_test.go index 5c06e659854..389093af178 100644 --- a/github/licenses_test.go +++ b/github/licenses_test.go @@ -14,7 +14,7 @@ import ( ) func TestLicensesService_List(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/licenses", func(w http.ResponseWriter, r *http.Request) { @@ -41,7 +41,7 @@ func TestLicensesService_List(t *testing.T) { } func TestLicensesService_Get(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/licenses/mit", func(w http.ResponseWriter, r *http.Request) { @@ -62,6 +62,9 @@ func TestLicensesService_Get(t *testing.T) { } func TestLicensesService_Get_invalidTemplate(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Licenses.Get(context.Background(), "%") testURLParseError(t, err) } diff --git a/github/migrations_source_import_test.go b/github/migrations_source_import_test.go index 67b98fb42b9..0bf92d7d1a8 100644 --- a/github/migrations_source_import_test.go +++ b/github/migrations_source_import_test.go @@ -15,7 +15,7 @@ import ( ) func TestMigrationService_StartImport(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Import{ @@ -50,7 +50,7 @@ func TestMigrationService_StartImport(t *testing.T) { } func TestMigrationService_ImportProgress(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestMigrationService_ImportProgress(t *testing.T) { } func TestMigrationService_UpdateImport(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Import{ @@ -105,7 +105,7 @@ func TestMigrationService_UpdateImport(t *testing.T) { } func TestMigrationService_CommitAuthors(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import/authors", func(w http.ResponseWriter, r *http.Request) { @@ -128,7 +128,7 @@ func TestMigrationService_CommitAuthors(t *testing.T) { } func TestMigrationService_MapCommitAuthor(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &SourceImportAuthor{Name: String("n"), Email: String("e")} @@ -157,7 +157,7 @@ func TestMigrationService_MapCommitAuthor(t *testing.T) { } func TestMigrationService_SetLFSPreference(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Import{UseLFS: String("opt_in")} @@ -187,7 +187,7 @@ func TestMigrationService_SetLFSPreference(t *testing.T) { } func TestMigrationService_LargeFiles(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import/large_files", func(w http.ResponseWriter, r *http.Request) { @@ -210,7 +210,7 @@ func TestMigrationService_LargeFiles(t *testing.T) { } func TestMigrationService_CancelImport(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/migrations_test.go b/github/migrations_test.go index 7e0ac0f7506..d318e9ec4e2 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -15,7 +15,7 @@ import ( ) func TestMigrationService_StartMigration(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestMigrationService_StartMigration(t *testing.T) { } func TestMigrationService_ListMigrations(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations", func(w http.ResponseWriter, r *http.Request) { @@ -61,7 +61,7 @@ func TestMigrationService_ListMigrations(t *testing.T) { } func TestMigrationService_MigrationStatus(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1", func(w http.ResponseWriter, r *http.Request) { @@ -82,7 +82,7 @@ func TestMigrationService_MigrationStatus(t *testing.T) { } func TestMigrationService_MigrationArchiveURL(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) { @@ -108,7 +108,7 @@ func TestMigrationService_MigrationArchiveURL(t *testing.T) { } func TestMigrationService_DeleteMigration(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) { @@ -124,7 +124,7 @@ func TestMigrationService_DeleteMigration(t *testing.T) { } func TestMigrationService_UnlockRepo(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/repos/r/lock", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/misc_test.go b/github/misc_test.go index f2b2df44b5e..21c471a59de 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -15,7 +15,7 @@ import ( ) func TestMarkdown(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &markdownRequest{ @@ -48,7 +48,7 @@ func TestMarkdown(t *testing.T) { } func TestListEmojis(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/emojis", func(w http.ResponseWriter, r *http.Request) { @@ -68,7 +68,7 @@ func TestListEmojis(t *testing.T) { } func TestListCodesOfConduct(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/codes_of_conduct", func(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func TestListCodesOfConduct(t *testing.T) { } func TestGetCodeOfConduct(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/codes_of_conduct/k", func(w http.ResponseWriter, r *http.Request) { @@ -129,7 +129,7 @@ func TestGetCodeOfConduct(t *testing.T) { } func TestAPIMeta(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/meta", func(w http.ResponseWriter, r *http.Request) { @@ -154,7 +154,7 @@ func TestAPIMeta(t *testing.T) { } func TestOctocat(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := "input" @@ -178,7 +178,7 @@ func TestOctocat(t *testing.T) { } func TestZen(t *testing.T) { - setup() + client, teardown := setup() defer teardown() output := "sample text" @@ -200,7 +200,7 @@ func TestZen(t *testing.T) { } func TestListServiceHooks(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/hooks", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_hooks_test.go b/github/orgs_hooks_test.go index 69e75f9f4ac..96317f72924 100644 --- a/github/orgs_hooks_test.go +++ b/github/orgs_hooks_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListHooks(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks", func(w http.ResponseWriter, r *http.Request) { @@ -38,12 +38,15 @@ func TestOrganizationsService_ListHooks(t *testing.T) { } func TestOrganizationsService_ListHooks_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.ListHooks(context.Background(), "%", nil) testURLParseError(t, err) } func TestOrganizationsService_GetHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -63,12 +66,15 @@ func TestOrganizationsService_GetHook(t *testing.T) { } func TestOrganizationsService_GetHook_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.GetHook(context.Background(), "%", 1) testURLParseError(t, err) } func TestOrganizationsService_EditHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -97,12 +103,15 @@ func TestOrganizationsService_EditHook(t *testing.T) { } func TestOrganizationsService_EditHook_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.EditHook(context.Background(), "%", 1, nil) testURLParseError(t, err) } func TestOrganizationsService_PingHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) { @@ -116,7 +125,7 @@ func TestOrganizationsService_PingHook(t *testing.T) { } func TestOrganizationsService_DeleteHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -130,6 +139,9 @@ func TestOrganizationsService_DeleteHook(t *testing.T) { } func TestOrganizationsService_DeleteHook_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Organizations.DeleteHook(context.Background(), "%", 1) testURLParseError(t, err) } diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 21fbeeaf38f..c6d5220fc72 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -16,7 +16,7 @@ import ( ) func TestOrganizationsService_ListMembers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members", func(w http.ResponseWriter, r *http.Request) { @@ -47,12 +47,15 @@ func TestOrganizationsService_ListMembers(t *testing.T) { } func TestOrganizationsService_ListMembers_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.ListMembers(context.Background(), "%", nil) testURLParseError(t, err) } func TestOrganizationsService_ListMembers_public(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +76,7 @@ func TestOrganizationsService_ListMembers_public(t *testing.T) { } func TestOrganizationsService_IsMember(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -92,7 +95,7 @@ func TestOrganizationsService_IsMember(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsMember_notMember(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -112,7 +115,7 @@ func TestOrganizationsService_IsMember_notMember(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsMember_error(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -130,12 +133,15 @@ func TestOrganizationsService_IsMember_error(t *testing.T) { } func TestOrganizationsService_IsMember_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.IsMember(context.Background(), "%", "u") testURLParseError(t, err) } func TestOrganizationsService_IsPublicMember(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -154,7 +160,7 @@ func TestOrganizationsService_IsPublicMember(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -174,7 +180,7 @@ func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsPublicMember_error(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -192,12 +198,15 @@ func TestOrganizationsService_IsPublicMember_error(t *testing.T) { } func TestOrganizationsService_IsPublicMember_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.IsPublicMember(context.Background(), "%", "u") testURLParseError(t, err) } func TestOrganizationsService_RemoveMember(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -211,12 +220,15 @@ func TestOrganizationsService_RemoveMember(t *testing.T) { } func TestOrganizationsService_RemoveMember_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Organizations.RemoveMember(context.Background(), "%", "u") testURLParseError(t, err) } func TestOrganizationsService_ListOrgMemberships(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/memberships/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -244,7 +256,7 @@ func TestOrganizationsService_ListOrgMemberships(t *testing.T) { } func TestOrganizationsService_GetOrgMembership_AuthenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/memberships/orgs/o", func(w http.ResponseWriter, r *http.Request) { @@ -264,7 +276,7 @@ func TestOrganizationsService_GetOrgMembership_AuthenticatedUser(t *testing.T) { } func TestOrganizationsService_GetOrgMembership_SpecifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -284,7 +296,7 @@ func TestOrganizationsService_GetOrgMembership_SpecifiedUser(t *testing.T) { } func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Membership{State: String("active")} @@ -313,7 +325,7 @@ func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) } func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Membership{State: String("active")} @@ -342,7 +354,7 @@ func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) { } func TestOrganizationsService_RemoveOrgMembership(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -357,7 +369,7 @@ func TestOrganizationsService_RemoveOrgMembership(t *testing.T) { } func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/invitations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_outside_collaborators_test.go b/github/orgs_outside_collaborators_test.go index 536006119b0..962103fc270 100644 --- a/github/orgs_outside_collaborators_test.go +++ b/github/orgs_outside_collaborators_test.go @@ -14,7 +14,7 @@ import ( ) func TestOrganizationsService_ListOutsideCollaborators(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/outside_collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -42,6 +42,9 @@ func TestOrganizationsService_ListOutsideCollaborators(t *testing.T) { } func TestOrganizationsService_ListOutsideCollaborators_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.ListOutsideCollaborators(context.Background(), "%", nil) testURLParseError(t, err) } diff --git a/github/orgs_projects_test.go b/github/orgs_projects_test.go index 533f691968d..4b8dfb9e2f3 100644 --- a/github/orgs_projects_test.go +++ b/github/orgs_projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListProjects(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/projects", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestOrganizationsService_ListProjects(t *testing.T) { } func TestOrganizationsService_CreateProject(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body."} diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index ff1101dc57a..67c47c22100 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -16,7 +16,7 @@ import ( ) func TestOrganizationsService_ListTeams(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/teams", func(w http.ResponseWriter, r *http.Request) { @@ -38,12 +38,15 @@ func TestOrganizationsService_ListTeams(t *testing.T) { } func TestOrganizationsService_ListTeams_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.ListTeams(context.Background(), "%", nil) testURLParseError(t, err) } func TestOrganizationsService_GetTeam(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { @@ -63,7 +66,7 @@ func TestOrganizationsService_GetTeam(t *testing.T) { } func TestOrganizationsService_CreateTeam(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Team{Name: String("n"), Privacy: String("closed")} @@ -92,12 +95,15 @@ func TestOrganizationsService_CreateTeam(t *testing.T) { } func TestOrganizationsService_CreateTeam_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.CreateTeam(context.Background(), "%", nil) testURLParseError(t, err) } func TestOrganizationsService_EditTeam(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Team{Name: String("n"), Privacy: String("closed")} @@ -126,7 +132,7 @@ func TestOrganizationsService_EditTeam(t *testing.T) { } func TestOrganizationsService_DeleteTeam(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { @@ -140,7 +146,7 @@ func TestOrganizationsService_DeleteTeam(t *testing.T) { } func TestOrganizationsService_ListTeamMembers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members", func(w http.ResponseWriter, r *http.Request) { @@ -162,7 +168,7 @@ func TestOrganizationsService_ListTeamMembers(t *testing.T) { } func TestOrganizationsService_IsTeamMember_true(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -180,7 +186,7 @@ func TestOrganizationsService_IsTeamMember_true(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsTeamMember_false(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -200,7 +206,7 @@ func TestOrganizationsService_IsTeamMember_false(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsTeamMember_error(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -218,12 +224,15 @@ func TestOrganizationsService_IsTeamMember_error(t *testing.T) { } func TestOrganizationsService_IsTeamMember_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.IsTeamMember(context.Background(), 1, "%") testURLParseError(t, err) } func TestOrganizationsService_PublicizeMembership(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -238,12 +247,15 @@ func TestOrganizationsService_PublicizeMembership(t *testing.T) { } func TestOrganizationsService_PublicizeMembership_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Organizations.PublicizeMembership(context.Background(), "%", "u") testURLParseError(t, err) } func TestOrganizationsService_ConcealMembership(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -258,12 +270,15 @@ func TestOrganizationsService_ConcealMembership(t *testing.T) { } func TestOrganizationsService_ConcealMembership_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Organizations.ConcealMembership(context.Background(), "%", "u") testURLParseError(t, err) } func TestOrganizationsService_ListTeamRepos(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos", func(w http.ResponseWriter, r *http.Request) { @@ -286,7 +301,7 @@ func TestOrganizationsService_ListTeamRepos(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_true(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -307,7 +322,7 @@ func TestOrganizationsService_IsTeamRepo_true(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_false(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -328,7 +343,7 @@ func TestOrganizationsService_IsTeamRepo_false(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_error(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -349,12 +364,15 @@ func TestOrganizationsService_IsTeamRepo_error(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.IsTeamRepo(context.Background(), 1, "%", "r") testURLParseError(t, err) } func TestOrganizationsService_AddTeamRepo(t *testing.T) { - setup() + client, teardown := setup() defer teardown() opt := &OrganizationAddTeamRepoOptions{Permission: "admin"} @@ -378,7 +396,7 @@ func TestOrganizationsService_AddTeamRepo(t *testing.T) { } func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -393,12 +411,15 @@ func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) { } func TestOrganizationsService_AddTeamRepo_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Organizations.AddTeamRepo(context.Background(), 1, "%", "r", nil) testURLParseError(t, err) } func TestOrganizationsService_RemoveTeamRepo(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -413,12 +434,15 @@ func TestOrganizationsService_RemoveTeamRepo(t *testing.T) { } func TestOrganizationsService_RemoveTeamRepo_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Organizations.RemoveTeamRepo(context.Background(), 1, "%", "r") testURLParseError(t, err) } func TestOrganizationsService_GetTeamMembership(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -438,7 +462,7 @@ func TestOrganizationsService_GetTeamMembership(t *testing.T) { } func TestOrganizationsService_AddTeamMembership(t *testing.T) { - setup() + client, teardown := setup() defer teardown() opt := &OrganizationAddTeamMembershipOptions{Role: "maintainer"} @@ -467,7 +491,7 @@ func TestOrganizationsService_AddTeamMembership(t *testing.T) { } func TestOrganizationsService_RemoveTeamMembership(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -482,7 +506,7 @@ func TestOrganizationsService_RemoveTeamMembership(t *testing.T) { } func TestOrganizationsService_ListUserTeams(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/teams", func(w http.ResponseWriter, r *http.Request) { @@ -504,7 +528,7 @@ func TestOrganizationsService_ListUserTeams(t *testing.T) { } func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/invitations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_test.go b/github/orgs_test.go index 6e227e8e555..2b48df7b790 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListAll(t *testing.T) { - setup() + client, teardown := setup() defer teardown() since := 1342004 @@ -38,7 +38,7 @@ func TestOrganizationsService_ListAll(t *testing.T) { } func TestOrganizationsService_List_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestOrganizationsService_List_authenticatedUser(t *testing.T) { } func TestOrganizationsService_List_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -80,12 +80,15 @@ func TestOrganizationsService_List_specifiedUser(t *testing.T) { } func TestOrganizationsService_List_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.List(context.Background(), "%", nil) testURLParseError(t, err) } func TestOrganizationsService_Get(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) { @@ -105,12 +108,15 @@ func TestOrganizationsService_Get(t *testing.T) { } func TestOrganizationsService_Get_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.Get(context.Background(), "%") testURLParseError(t, err) } func TestOrganizationsService_GetByID(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/organizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -130,7 +136,7 @@ func TestOrganizationsService_GetByID(t *testing.T) { } func TestOrganizationsService_Edit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Organization{Login: String("l")} @@ -159,6 +165,9 @@ func TestOrganizationsService_Edit(t *testing.T) { } func TestOrganizationsService_Edit_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Organizations.Edit(context.Background(), "%", nil) testURLParseError(t, err) } diff --git a/github/orgs_users_blocking_test.go b/github/orgs_users_blocking_test.go index 53be507ef21..a85aead488c 100644 --- a/github/orgs_users_blocking_test.go +++ b/github/orgs_users_blocking_test.go @@ -14,7 +14,7 @@ import ( ) func TestOrganizationsService_ListBlockedUsers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestOrganizationsService_ListBlockedUsers(t *testing.T) { } func TestOrganizationsService_IsBlocked(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestOrganizationsService_IsBlocked(t *testing.T) { } func TestOrganizationsService_BlockUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func TestOrganizationsService_BlockUser(t *testing.T) { } func TestOrganizationsService_UnblockUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/projects_test.go b/github/projects_test.go index bf287e0263b..cd61ea662e0 100644 --- a/github/projects_test.go +++ b/github/projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestProjectsService_UpdateProject(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body.", State: "open"} @@ -45,7 +45,7 @@ func TestProjectsService_UpdateProject(t *testing.T) { } func TestProjectsService_GetProject(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { @@ -66,7 +66,7 @@ func TestProjectsService_GetProject(t *testing.T) { } func TestProjectsService_DeleteProject(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { @@ -81,7 +81,7 @@ func TestProjectsService_DeleteProject(t *testing.T) { } func TestProjectsService_ListProjectColumns(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/projects/1/columns", func(w http.ResponseWriter, r *http.Request) { @@ -104,7 +104,7 @@ func TestProjectsService_ListProjectColumns(t *testing.T) { } func TestProjectsService_GetProjectColumn(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestProjectsService_GetProjectColumn(t *testing.T) { } func TestProjectsService_CreateProjectColumn(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectColumnOptions{Name: "Column Name"} @@ -155,7 +155,7 @@ func TestProjectsService_CreateProjectColumn(t *testing.T) { } func TestProjectsService_UpdateProjectColumn(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectColumnOptions{Name: "Column Name"} @@ -185,7 +185,7 @@ func TestProjectsService_UpdateProjectColumn(t *testing.T) { } func TestProjectsService_DeleteProjectColumn(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { @@ -200,7 +200,7 @@ func TestProjectsService_DeleteProjectColumn(t *testing.T) { } func TestProjectsService_MoveProjectColumn(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectColumnMoveOptions{Position: "after:12345"} @@ -223,7 +223,7 @@ func TestProjectsService_MoveProjectColumn(t *testing.T) { } func TestProjectsService_ListProjectCards(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1/cards", func(w http.ResponseWriter, r *http.Request) { @@ -246,7 +246,7 @@ func TestProjectsService_ListProjectCards(t *testing.T) { } func TestProjectsService_GetProjectCard(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { @@ -267,7 +267,7 @@ func TestProjectsService_GetProjectCard(t *testing.T) { } func TestProjectsService_CreateProjectCard(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectCardOptions{ @@ -300,7 +300,7 @@ func TestProjectsService_CreateProjectCard(t *testing.T) { } func TestProjectsService_UpdateProjectCard(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectCardOptions{ @@ -333,7 +333,7 @@ func TestProjectsService_UpdateProjectCard(t *testing.T) { } func TestProjectsService_DeleteProjectCard(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { @@ -348,7 +348,7 @@ func TestProjectsService_DeleteProjectCard(t *testing.T) { } func TestProjectsService_MoveProjectCard(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectCardMoveOptions{Position: "after:12345"} diff --git a/github/pulls_comments_test.go b/github/pulls_comments_test.go index e35b04f7b7b..0e7fb96e757 100644 --- a/github/pulls_comments_test.go +++ b/github/pulls_comments_test.go @@ -16,7 +16,7 @@ import ( ) func TestPullRequestsService_ListComments_allPulls(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) { } func TestPullRequestsService_ListComments_specificPull(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -70,12 +70,15 @@ func TestPullRequestsService_ListComments_specificPull(t *testing.T) { } func TestPullRequestsService_ListComments_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.ListComments(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestPullRequestsService_GetComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -96,12 +99,15 @@ func TestPullRequestsService_GetComment(t *testing.T) { } func TestPullRequestsService_GetComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.GetComment(context.Background(), "%", "r", 1) testURLParseError(t, err) } func TestPullRequestsService_CreateComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &PullRequestComment{Body: String("b")} @@ -130,12 +136,15 @@ func TestPullRequestsService_CreateComment(t *testing.T) { } func TestPullRequestsService_CreateComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.CreateComment(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestPullRequestsService_EditComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &PullRequestComment{Body: String("b")} @@ -164,12 +173,15 @@ func TestPullRequestsService_EditComment(t *testing.T) { } func TestPullRequestsService_EditComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.EditComment(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestPullRequestsService_DeleteComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -183,6 +195,9 @@ func TestPullRequestsService_DeleteComment(t *testing.T) { } func TestPullRequestsService_DeleteComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.PullRequests.DeleteComment(context.Background(), "%", "r", 1) testURLParseError(t, err) } diff --git a/github/pulls_reviewers_test.go b/github/pulls_reviewers_test.go index fddea6d0891..3fda247e448 100644 --- a/github/pulls_reviewers_test.go +++ b/github/pulls_reviewers_test.go @@ -14,7 +14,7 @@ import ( ) func TestRequestReviewers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestRequestReviewers(t *testing.T) { } func TestRemoveReviewers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -52,7 +52,7 @@ func TestRemoveReviewers(t *testing.T) { } func TestListReviewers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -86,7 +86,7 @@ func TestListReviewers(t *testing.T) { } func TestListReviewers_withOptions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index b69d76adca9..e92a2869478 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -15,7 +15,7 @@ import ( ) func TestPullRequestsService_ListReviews(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) { @@ -42,12 +42,15 @@ func TestPullRequestsService_ListReviews(t *testing.T) { } func TestPullRequestsService_ListReviews_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.ListReviews(context.Background(), "%", "r", 1, nil) testURLParseError(t, err) } func TestPullRequestsService_GetReview(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { @@ -67,12 +70,15 @@ func TestPullRequestsService_GetReview(t *testing.T) { } func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.GetReview(context.Background(), "%", "r", 1, 1) testURLParseError(t, err) } func TestPullRequestsService_DeletePendingReview(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { @@ -92,12 +98,15 @@ func TestPullRequestsService_DeletePendingReview(t *testing.T) { } func TestPullRequestsService_DeletePendingReview_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.DeletePendingReview(context.Background(), "%", "r", 1, 1) testURLParseError(t, err) } func TestPullRequestsService_ListReviewComments(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -120,7 +129,7 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) { } func TestPullRequestsService_ListReviewComments_withOptions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -138,12 +147,15 @@ func TestPullRequestsService_ListReviewComments_withOptions(t *testing.T) { } func TestPullRequestsService_ListReviewComments_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.ListReviewComments(context.Background(), "%", "r", 1, 1, nil) testURLParseError(t, err) } func TestPullRequestsService_CreateReview(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &PullRequestReviewRequest{ @@ -176,12 +188,15 @@ func TestPullRequestsService_CreateReview(t *testing.T) { } func TestPullRequestsService_CreateReview_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.CreateReview(context.Background(), "%", "r", 1, &PullRequestReviewRequest{}) testURLParseError(t, err) } func TestPullRequestsService_SubmitReview(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &PullRequestReviewRequest{ @@ -213,12 +228,15 @@ func TestPullRequestsService_SubmitReview(t *testing.T) { } func TestPullRequestsService_SubmitReview_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.SubmitReview(context.Background(), "%", "r", 1, 1, &PullRequestReviewRequest{}) testURLParseError(t, err) } func TestPullRequestsService_DismissReview(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &PullRequestReviewDismissalRequest{Message: String("m")} @@ -247,6 +265,9 @@ func TestPullRequestsService_DismissReview(t *testing.T) { } func TestPullRequestsService_DismissReview_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.DismissReview(context.Background(), "%", "r", 1, 1, &PullRequestReviewDismissalRequest{}) testURLParseError(t, err) } diff --git a/github/pulls_test.go b/github/pulls_test.go index ea31e521651..101a8db572c 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -17,7 +17,7 @@ import ( ) func TestPullRequestsService_List(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) { @@ -46,12 +46,15 @@ func TestPullRequestsService_List(t *testing.T) { } func TestPullRequestsService_List_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.List(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestPullRequestsService_Get(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -71,7 +74,7 @@ func TestPullRequestsService_Get(t *testing.T) { } func TestPullRequestsService_GetRawDiff(t *testing.T) { - setup() + client, teardown := setup() defer teardown() const rawStr = "@@diff content" @@ -92,7 +95,7 @@ func TestPullRequestsService_GetRawDiff(t *testing.T) { } func TestPullRequestsService_GetRawPatch(t *testing.T) { - setup() + client, teardown := setup() defer teardown() const rawStr = "@@patch content" @@ -113,7 +116,7 @@ func TestPullRequestsService_GetRawPatch(t *testing.T) { } func TestPullRequestsService_GetRawInvalid(t *testing.T) { - setup() + client, teardown := setup() defer teardown() _, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{100}) @@ -126,7 +129,7 @@ func TestPullRequestsService_GetRawInvalid(t *testing.T) { } func TestPullRequestsService_Get_headAndBase(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -156,7 +159,7 @@ func TestPullRequestsService_Get_headAndBase(t *testing.T) { } func TestPullRequestsService_Get_urlFields(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -195,12 +198,15 @@ func TestPullRequestsService_Get_urlFields(t *testing.T) { } func TestPullRequestsService_Get_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.Get(context.Background(), "%", "r", 1) testURLParseError(t, err) } func TestPullRequestsService_Create(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &NewPullRequest{Title: String("t")} @@ -229,12 +235,15 @@ func TestPullRequestsService_Create(t *testing.T) { } func TestPullRequestsService_Create_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.Create(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestPullRequestsService_Edit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() tests := []struct { @@ -287,12 +296,15 @@ func TestPullRequestsService_Edit(t *testing.T) { } func TestPullRequestsService_Edit_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.PullRequests.Edit(context.Background(), "%", "r", 1, &PullRequest{}) testURLParseError(t, err) } func TestPullRequestsService_ListCommits(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -350,7 +362,7 @@ func TestPullRequestsService_ListCommits(t *testing.T) { } func TestPullRequestsService_ListFiles(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/files", func(w http.ResponseWriter, r *http.Request) { @@ -412,7 +424,7 @@ func TestPullRequestsService_ListFiles(t *testing.T) { } func TestPullRequestsService_IsMerged(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) { @@ -432,7 +444,7 @@ func TestPullRequestsService_IsMerged(t *testing.T) { } func TestPullRequestsService_Merge(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) { @@ -463,7 +475,7 @@ func TestPullRequestsService_Merge(t *testing.T) { // Test that different merge options produce expected PUT requests. See issue https://github.com/google/go-github/issues/500. func TestPullRequestsService_Merge_options(t *testing.T) { - setup() + client, teardown := setup() defer teardown() tests := []struct { diff --git a/github/reactions_test.go b/github/reactions_test.go index 2725298279e..83b127e68e2 100644 --- a/github/reactions_test.go +++ b/github/reactions_test.go @@ -13,7 +13,7 @@ import ( ) func TestReactionsService_ListCommentReactions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -34,7 +34,7 @@ func TestReactionsService_ListCommentReactions(t *testing.T) { } func TestReactionsService_CreateCommentReaction(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -56,7 +56,7 @@ func TestReactionsService_CreateCommentReaction(t *testing.T) { } func TestReactionsService_ListIssueReactions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -77,7 +77,7 @@ func TestReactionsService_ListIssueReactions(t *testing.T) { } func TestReactionsService_CreateIssueReaction(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -99,7 +99,7 @@ func TestReactionsService_CreateIssueReaction(t *testing.T) { } func TestReactionsService_ListIssueCommentReactions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -120,7 +120,7 @@ func TestReactionsService_ListIssueCommentReactions(t *testing.T) { } func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -142,7 +142,7 @@ func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { } func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -163,7 +163,7 @@ func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { } func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -185,7 +185,7 @@ func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { } func TestReactionsService_DeleteReaction(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/reactions/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index 4ac23934c7e..7e234e1899c 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListCollaborators(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) { } func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -64,12 +64,15 @@ func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) { } func TestRepositoriesService_ListCollaborators_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListCollaborators(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_IsCollaborator_True(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -88,7 +91,7 @@ func TestRepositoriesService_IsCollaborator_True(t *testing.T) { } func TestRepositoriesService_IsCollaborator_False(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -107,12 +110,15 @@ func TestRepositoriesService_IsCollaborator_False(t *testing.T) { } func TestRepositoriesService_IsCollaborator_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.IsCollaborator(context.Background(), "%", "%", "%") testURLParseError(t, err) } func TestRepositoryService_GetPermissionLevel(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u/permission", func(w http.ResponseWriter, r *http.Request) { @@ -138,7 +144,7 @@ func TestRepositoryService_GetPermissionLevel(t *testing.T) { } func TestRepositoriesService_AddCollaborator(t *testing.T) { - setup() + client, teardown := setup() defer teardown() opt := &RepositoryAddCollaboratorOptions{Permission: "admin"} @@ -163,12 +169,15 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) { } func TestRepositoriesService_AddCollaborator_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Repositories.AddCollaborator(context.Background(), "%", "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_RemoveCollaborator(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -183,6 +192,9 @@ func TestRepositoriesService_RemoveCollaborator(t *testing.T) { } func TestRepositoriesService_RemoveCollaborator_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Repositories.RemoveCollaborator(context.Background(), "%", "%", "%") testURLParseError(t, err) } diff --git a/github/repos_comments_test.go b/github/repos_comments_test.go index 249a37a3677..44644cd3ff8 100644 --- a/github/repos_comments_test.go +++ b/github/repos_comments_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListComments(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments", func(w http.ResponseWriter, r *http.Request) { @@ -38,12 +38,15 @@ func TestRepositoriesService_ListComments(t *testing.T) { } func TestRepositoriesService_ListComments_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListComments(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_ListCommitComments(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/s/comments", func(w http.ResponseWriter, r *http.Request) { @@ -66,12 +69,15 @@ func TestRepositoriesService_ListCommitComments(t *testing.T) { } func TestRepositoriesService_ListCommitComments_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListCommitComments(context.Background(), "%", "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_CreateComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &RepositoryComment{Body: String("b")} @@ -100,12 +106,15 @@ func TestRepositoriesService_CreateComment(t *testing.T) { } func TestRepositoriesService_CreateComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.CreateComment(context.Background(), "%", "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_GetComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -126,12 +135,15 @@ func TestRepositoriesService_GetComment(t *testing.T) { } func TestRepositoriesService_GetComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.GetComment(context.Background(), "%", "%", 1) testURLParseError(t, err) } func TestRepositoriesService_UpdateComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &RepositoryComment{Body: String("b")} @@ -160,12 +172,15 @@ func TestRepositoriesService_UpdateComment(t *testing.T) { } func TestRepositoriesService_UpdateComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.UpdateComment(context.Background(), "%", "%", 1, nil) testURLParseError(t, err) } func TestRepositoriesService_DeleteComment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -179,6 +194,9 @@ func TestRepositoriesService_DeleteComment(t *testing.T) { } func TestRepositoriesService_DeleteComment_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Repositories.DeleteComment(context.Background(), "%", "%", 1) testURLParseError(t, err) } diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 98eadabb3fd..22622979903 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListCommits(t *testing.T) { - setup() + client, teardown := setup() defer teardown() // given @@ -52,7 +52,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) { } func TestRepositoriesService_GetCommit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) { @@ -127,7 +127,7 @@ func TestRepositoriesService_GetCommit(t *testing.T) { } func TestRepositoriesService_GetCommitSHA1(t *testing.T) { - setup() + client, teardown := setup() defer teardown() const sha1 = "01234abcde" @@ -168,7 +168,7 @@ func TestRepositoriesService_GetCommitSHA1(t *testing.T) { } func TestRepositoriesService_CompareCommits(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/compare/b...h", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_community_health_test.go b/github/repos_community_health_test.go index a90c8c03802..5bc65962263 100644 --- a/github/repos_community_health_test.go +++ b/github/repos_community_health_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/community/profile", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 770098e8c31..2d5f7ee5df2 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -68,7 +68,7 @@ func TestRepositoryContent_GetContent(t *testing.T) { } func TestRepositoriesService_GetReadme(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/readme", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -91,7 +91,7 @@ func TestRepositoriesService_GetReadme(t *testing.T) { } func TestRepositoriesService_DownloadContents_Success(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -123,7 +123,7 @@ func TestRepositoriesService_DownloadContents_Success(t *testing.T) { } func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -140,7 +140,7 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { } func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -154,7 +154,7 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { } func TestRepositoriesService_GetContents_File(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -177,7 +177,7 @@ func TestRepositoriesService_GetContents_File(t *testing.T) { } func TestRepositoriesService_GetContents_FilenameNeedsEscape(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p#?%/δΈ­.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -190,7 +190,7 @@ func TestRepositoriesService_GetContents_FilenameNeedsEscape(t *testing.T) { } func TestRepositoriesService_GetContents_DirectoryWithSpaces(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/some directory/file.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -203,7 +203,7 @@ func TestRepositoriesService_GetContents_DirectoryWithSpaces(t *testing.T) { } func TestRepositoriesService_GetContents_DirectoryWithPlusChars(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/some directory+name/file.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -216,7 +216,7 @@ func TestRepositoriesService_GetContents_DirectoryWithPlusChars(t *testing.T) { } func TestRepositoriesService_GetContents_Directory(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -244,7 +244,7 @@ func TestRepositoriesService_GetContents_Directory(t *testing.T) { } func TestRepositoriesService_CreateFile(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -282,7 +282,7 @@ func TestRepositoriesService_CreateFile(t *testing.T) { } func TestRepositoriesService_UpdateFile(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -322,7 +322,7 @@ func TestRepositoriesService_UpdateFile(t *testing.T) { } func TestRepositoriesService_DeleteFile(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") @@ -358,7 +358,7 @@ func TestRepositoriesService_DeleteFile(t *testing.T) { } func TestRepositoriesService_GetArchiveLink(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/tarball", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") diff --git a/github/repos_deployments_test.go b/github/repos_deployments_test.go index 9fa44b2ba4c..c23316b79dd 100644 --- a/github/repos_deployments_test.go +++ b/github/repos_deployments_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListDeployments(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListDeployments(t *testing.T) { } func TestRepositoriesService_GetDeployment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/3", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestRepositoriesService_GetDeployment(t *testing.T) { } func TestRepositoriesService_CreateDeployment(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &DeploymentRequest{Ref: String("1111"), Task: String("deploy"), TransientEnvironment: Bool(true)} @@ -88,7 +88,7 @@ func TestRepositoriesService_CreateDeployment(t *testing.T) { } func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/1/statuses", func(w http.ResponseWriter, r *http.Request) { @@ -110,7 +110,7 @@ func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) { } func TestRepositoriesService_GetDeploymentStatus(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/3/statuses/4", func(w http.ResponseWriter, r *http.Request) { @@ -131,7 +131,7 @@ func TestRepositoriesService_GetDeploymentStatus(t *testing.T) { } func TestRepositoriesService_CreateDeploymentStatus(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &DeploymentStatusRequest{State: String("inactive"), Description: String("deploy"), AutoInactive: Bool(false)} diff --git a/github/repos_forks_test.go b/github/repos_forks_test.go index f9cf1e3a325..09172b7fa16 100644 --- a/github/repos_forks_test.go +++ b/github/repos_forks_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_ListForks(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { @@ -43,12 +43,15 @@ func TestRepositoriesService_ListForks(t *testing.T) { } func TestRepositoriesService_ListForks_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListForks(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestRepositoriesService_CreateFork(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { @@ -70,6 +73,9 @@ func TestRepositoriesService_CreateFork(t *testing.T) { } func TestRepositoriesService_CreateFork_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.CreateFork(context.Background(), "%", "r", nil) testURLParseError(t, err) } diff --git a/github/repos_hooks_test.go b/github/repos_hooks_test.go index 364f4583f08..fdd6544d7e2 100644 --- a/github/repos_hooks_test.go +++ b/github/repos_hooks_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_CreateHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -44,12 +44,15 @@ func TestRepositoriesService_CreateHook(t *testing.T) { } func TestRepositoriesService_CreateHook_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.CreateHook(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_ListHooks(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks", func(w http.ResponseWriter, r *http.Request) { @@ -72,12 +75,15 @@ func TestRepositoriesService_ListHooks(t *testing.T) { } func TestRepositoriesService_ListHooks_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListHooks(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_GetHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -97,12 +103,15 @@ func TestRepositoriesService_GetHook(t *testing.T) { } func TestRepositoriesService_GetHook_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.GetHook(context.Background(), "%", "%", 1) testURLParseError(t, err) } func TestRepositoriesService_EditHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -131,12 +140,15 @@ func TestRepositoriesService_EditHook(t *testing.T) { } func TestRepositoriesService_EditHook_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.EditHook(context.Background(), "%", "%", 1, nil) testURLParseError(t, err) } func TestRepositoriesService_DeleteHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -150,12 +162,15 @@ func TestRepositoriesService_DeleteHook(t *testing.T) { } func TestRepositoriesService_DeleteHook_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Repositories.DeleteHook(context.Background(), "%", "%", 1) testURLParseError(t, err) } func TestRepositoriesService_PingHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) { @@ -169,7 +184,7 @@ func TestRepositoriesService_PingHook(t *testing.T) { } func TestRepositoriesService_TestHook(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1/tests", func(w http.ResponseWriter, r *http.Request) { @@ -183,6 +198,9 @@ func TestRepositoriesService_TestHook(t *testing.T) { } func TestRepositoriesService_TestHook_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Repositories.TestHook(context.Background(), "%", "%", 1) testURLParseError(t, err) } diff --git a/github/repos_invitations_test.go b/github/repos_invitations_test.go index 01ac66657fc..9dbadd80cdd 100644 --- a/github/repos_invitations_test.go +++ b/github/repos_invitations_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_ListInvitations(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListInvitations(t *testing.T) { } func TestRepositoriesService_DeleteInvitation(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) { @@ -53,7 +53,7 @@ func TestRepositoriesService_DeleteInvitation(t *testing.T) { } func TestRepositoriesService_UpdateInvitation(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_keys_test.go b/github/repos_keys_test.go index 2ef04fdcb62..e314e748c37 100644 --- a/github/repos_keys_test.go +++ b/github/repos_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListKeys(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys", func(w http.ResponseWriter, r *http.Request) { @@ -37,12 +37,15 @@ func TestRepositoriesService_ListKeys(t *testing.T) { } func TestRepositoriesService_ListKeys_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListKeys(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_GetKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -62,12 +65,15 @@ func TestRepositoriesService_GetKey(t *testing.T) { } func TestRepositoriesService_GetKey_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.GetKey(context.Background(), "%", "%", 1) testURLParseError(t, err) } func TestRepositoriesService_CreateKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -96,12 +102,15 @@ func TestRepositoriesService_CreateKey(t *testing.T) { } func TestRepositoriesService_CreateKey_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.CreateKey(context.Background(), "%", "%", nil) testURLParseError(t, err) } func TestRepositoriesService_EditKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -130,12 +139,15 @@ func TestRepositoriesService_EditKey(t *testing.T) { } func TestRepositoriesService_EditKey_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.EditKey(context.Background(), "%", "%", 1, nil) testURLParseError(t, err) } func TestRepositoriesService_DeleteKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -149,6 +161,9 @@ func TestRepositoriesService_DeleteKey(t *testing.T) { } func TestRepositoriesService_DeleteKey_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Repositories.DeleteKey(context.Background(), "%", "%", 1) testURLParseError(t, err) } diff --git a/github/repos_merging_test.go b/github/repos_merging_test.go index e2e264fd660..4f19f77aab9 100644 --- a/github/repos_merging_test.go +++ b/github/repos_merging_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_Merge(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &RepositoryMergeRequest{ diff --git a/github/repos_pages_test.go b/github/repos_pages_test.go index c9e19a1f5a1..d08655740b6 100644 --- a/github/repos_pages_test.go +++ b/github/repos_pages_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_GetPagesInfo(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { @@ -35,7 +35,7 @@ func TestRepositoriesService_GetPagesInfo(t *testing.T) { } func TestRepositoriesService_ListPagesBuilds(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { @@ -55,7 +55,7 @@ func TestRepositoriesService_ListPagesBuilds(t *testing.T) { } func TestRepositoriesService_ListPagesBuilds_withOptions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestRepositoriesService_ListPagesBuilds_withOptions(t *testing.T) { } func TestRepositoriesService_GetLatestPagesBuild(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds/latest", func(w http.ResponseWriter, r *http.Request) { @@ -93,7 +93,7 @@ func TestRepositoriesService_GetLatestPagesBuild(t *testing.T) { } func TestRepositoriesService_GetPageBuild(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds/1", func(w http.ResponseWriter, r *http.Request) { @@ -113,7 +113,7 @@ func TestRepositoriesService_GetPageBuild(t *testing.T) { } func TestRepositoriesService_RequestPageBuild(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_projects_test.go b/github/repos_projects_test.go index 57dbdd1b3fe..441770a56e7 100644 --- a/github/repos_projects_test.go +++ b/github/repos_projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListProjects(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/projects", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestRepositoriesService_ListProjects(t *testing.T) { } func TestRepositoriesService_CreateProject(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body."} diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 9a2c4c8afff..bc6436ca496 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -19,7 +19,7 @@ import ( ) func TestRepositoriesService_ListReleases(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestRepositoriesService_ListReleases(t *testing.T) { } func TestRepositoriesService_GetRelease(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { @@ -60,7 +60,7 @@ func TestRepositoriesService_GetRelease(t *testing.T) { } func TestRepositoriesService_GetLatestRelease(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/latest", func(w http.ResponseWriter, r *http.Request) { @@ -80,7 +80,7 @@ func TestRepositoriesService_GetLatestRelease(t *testing.T) { } func TestRepositoriesService_GetReleaseByTag(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/tags/foo", func(w http.ResponseWriter, r *http.Request) { @@ -100,7 +100,7 @@ func TestRepositoriesService_GetReleaseByTag(t *testing.T) { } func TestRepositoriesService_CreateRelease(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &RepositoryRelease{Name: String("v1.0")} @@ -128,7 +128,7 @@ func TestRepositoriesService_CreateRelease(t *testing.T) { } func TestRepositoriesService_EditRelease(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &RepositoryRelease{Name: String("n")} @@ -155,7 +155,7 @@ func TestRepositoriesService_EditRelease(t *testing.T) { } func TestRepositoriesService_DeleteRelease(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { @@ -169,7 +169,7 @@ func TestRepositoriesService_DeleteRelease(t *testing.T) { } func TestRepositoriesService_ListReleaseAssets(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1/assets", func(w http.ResponseWriter, r *http.Request) { @@ -190,7 +190,7 @@ func TestRepositoriesService_ListReleaseAssets(t *testing.T) { } func TestRepositoriesService_GetReleaseAsset(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -209,7 +209,7 @@ func TestRepositoriesService_GetReleaseAsset(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_Stream(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -235,7 +235,7 @@ func TestRepositoriesService_DownloadReleaseAsset_Stream(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_Redirect(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -255,7 +255,7 @@ func TestRepositoriesService_DownloadReleaseAsset_Redirect(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_APIError(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -281,7 +281,7 @@ func TestRepositoriesService_DownloadReleaseAsset_APIError(t *testing.T) { } func TestRepositoriesService_EditReleaseAsset(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ReleaseAsset{Name: String("n")} @@ -308,7 +308,7 @@ func TestRepositoriesService_EditReleaseAsset(t *testing.T) { } func TestRepositoriesService_DeleteReleaseAsset(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -322,7 +322,7 @@ func TestRepositoriesService_DeleteReleaseAsset(t *testing.T) { } func TestRepositoriesService_UploadReleaseAsset(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1/assets", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 1da94d01338..63f0fc6887d 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListContributorsStats(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/contributors", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) { } func TestRepositoriesService_ListCommitActivity(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/commit_activity", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) { } func TestRepositoriesService_ListCodeFrequency(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/code_frequency", func(w http.ResponseWriter, r *http.Request) { @@ -131,7 +131,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) { } func TestRepositoriesService_Participation(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/participation", func(w http.ResponseWriter, r *http.Request) { @@ -181,7 +181,7 @@ func TestRepositoriesService_Participation(t *testing.T) { } func TestRepositoriesService_ListPunchCard(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/punch_card", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_statuses_test.go b/github/repos_statuses_test.go index 8e6c9378d27..b2c7db767c3 100644 --- a/github/repos_statuses_test.go +++ b/github/repos_statuses_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListStatuses(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/r/statuses", func(w http.ResponseWriter, r *http.Request) { @@ -37,12 +37,15 @@ func TestRepositoriesService_ListStatuses(t *testing.T) { } func TestRepositoriesService_ListStatuses_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListStatuses(context.Background(), "%", "r", "r", nil) testURLParseError(t, err) } func TestRepositoriesService_CreateStatus(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &RepoStatus{State: String("s"), TargetURL: String("t"), Description: String("d")} @@ -70,12 +73,15 @@ func TestRepositoriesService_CreateStatus(t *testing.T) { } func TestRepositoriesService_CreateStatus_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.CreateStatus(context.Background(), "%", "r", "r", nil) testURLParseError(t, err) } func TestRepositoriesService_GetCombinedStatus(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/r/status", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_test.go b/github/repos_test.go index 43f8bda70ec..897527f6296 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -16,7 +16,7 @@ import ( ) func TestRepositoriesService_List_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -38,7 +38,7 @@ func TestRepositoriesService_List_authenticatedUser(t *testing.T) { } func TestRepositoriesService_List_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -74,7 +74,7 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) { } func TestRepositoriesService_List_specifiedUser_type(t *testing.T) { - setup() + client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -102,12 +102,15 @@ func TestRepositoriesService_List_specifiedUser_type(t *testing.T) { } func TestRepositoriesService_List_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.List(context.Background(), "%", nil) testURLParseError(t, err) } func TestRepositoriesService_ListByOrg(t *testing.T) { - setup() + client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -134,12 +137,15 @@ func TestRepositoriesService_ListByOrg(t *testing.T) { } func TestRepositoriesService_ListByOrg_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListByOrg(context.Background(), "%", nil) testURLParseError(t, err) } func TestRepositoriesService_ListAll(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -163,7 +169,7 @@ func TestRepositoriesService_ListAll(t *testing.T) { } func TestRepositoriesService_Create_user(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Repository{Name: String("n")} @@ -192,7 +198,7 @@ func TestRepositoriesService_Create_user(t *testing.T) { } func TestRepositoriesService_Create_org(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Repository{Name: String("n")} @@ -221,12 +227,15 @@ func TestRepositoriesService_Create_org(t *testing.T) { } func TestRepositoriesService_Create_invalidOrg(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.Create(context.Background(), "%", nil) testURLParseError(t, err) } func TestRepositoriesService_Get(t *testing.T) { - setup() + client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -248,7 +257,7 @@ func TestRepositoriesService_Get(t *testing.T) { } func TestRepositoriesService_GetCodeOfConduct(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/community/code_of_conduct", func(w http.ResponseWriter, r *http.Request) { @@ -280,7 +289,7 @@ func TestRepositoriesService_GetCodeOfConduct(t *testing.T) { } func TestRepositoriesService_GetByID(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repositories/1", func(w http.ResponseWriter, r *http.Request) { @@ -301,7 +310,7 @@ func TestRepositoriesService_GetByID(t *testing.T) { } func TestRepositoriesService_Edit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() i := true @@ -330,7 +339,7 @@ func TestRepositoriesService_Edit(t *testing.T) { } func TestRepositoriesService_Delete(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -344,17 +353,23 @@ func TestRepositoriesService_Delete(t *testing.T) { } func TestRepositoriesService_Get_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.Get(context.Background(), "%", "r") testURLParseError(t, err) } func TestRepositoriesService_Edit_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.Edit(context.Background(), "%", "r", nil) testURLParseError(t, err) } func TestRepositoriesService_ListContributors(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contributors", func(w http.ResponseWriter, r *http.Request) { @@ -379,7 +394,7 @@ func TestRepositoriesService_ListContributors(t *testing.T) { } func TestRepositoriesService_ListLanguages(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/languages", func(w http.ResponseWriter, r *http.Request) { @@ -399,7 +414,7 @@ func TestRepositoriesService_ListLanguages(t *testing.T) { } func TestRepositoriesService_ListTeams(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/teams", func(w http.ResponseWriter, r *http.Request) { @@ -421,7 +436,7 @@ func TestRepositoriesService_ListTeams(t *testing.T) { } func TestRepositoriesService_ListTags(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/tags", func(w http.ResponseWriter, r *http.Request) { @@ -453,7 +468,7 @@ func TestRepositoriesService_ListTags(t *testing.T) { } func TestRepositoriesService_ListBranches(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches", func(w http.ResponseWriter, r *http.Request) { @@ -476,7 +491,7 @@ func TestRepositoriesService_ListBranches(t *testing.T) { } func TestRepositoriesService_GetBranch(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) { @@ -507,7 +522,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) { } func TestRepositoriesService_GetBranchProtection(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) { @@ -560,7 +575,7 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) { } func TestRepositoriesService_UpdateBranchProtection(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &ProtectionRequest{ @@ -630,7 +645,7 @@ func TestRepositoriesService_UpdateBranchProtection(t *testing.T) { } func TestRepositoriesService_RemoveBranchProtection(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) { @@ -646,12 +661,15 @@ func TestRepositoriesService_RemoveBranchProtection(t *testing.T) { } func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Repositories.ListLanguages(context.Background(), "%", "%") testURLParseError(t, err) } func TestRepositoriesService_License(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/license", func(w http.ResponseWriter, r *http.Request) { @@ -682,7 +700,7 @@ func TestRepositoriesService_License(t *testing.T) { } func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) { @@ -709,7 +727,7 @@ func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) { } func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks/contexts", func(w http.ResponseWriter, r *http.Request) { @@ -733,7 +751,7 @@ func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) { } func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -766,7 +784,7 @@ func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &PullRequestReviewsEnforcementUpdate{ @@ -811,7 +829,7 @@ func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -840,7 +858,7 @@ func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) { } func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -856,7 +874,7 @@ func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_GetAdminEnforcement(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -881,7 +899,7 @@ func TestRepositoriesService_GetAdminEnforcement(t *testing.T) { } func TestRepositoriesService_AddAdminEnforcement(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -905,7 +923,7 @@ func TestRepositoriesService_AddAdminEnforcement(t *testing.T) { } func TestRepositoriesService_RemoveAdminEnforcement(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -935,7 +953,7 @@ func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctio } func TestRepositoriesService_ListAllTopics(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -956,7 +974,7 @@ func TestRepositoriesService_ListAllTopics(t *testing.T) { } func TestRepositoriesService_ReplaceAllTopics(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index c425f5cd5d1..95750a9b18c 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListTrafficReferrers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/popular/referrers", func(w http.ResponseWriter, r *http.Request) { @@ -43,7 +43,7 @@ func TestRepositoriesService_ListTrafficReferrers(t *testing.T) { } func TestRepositoriesService_ListTrafficPaths(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/popular/paths", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestRepositoriesService_ListTrafficPaths(t *testing.T) { } func TestRepositoriesService_ListTrafficViews(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/views", func(w http.ResponseWriter, r *http.Request) { @@ -109,7 +109,7 @@ func TestRepositoriesService_ListTrafficViews(t *testing.T) { } func TestRepositoriesService_ListTrafficClones(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/clones", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/search_test.go b/github/search_test.go index 1276e01d8b2..8b3ec66c004 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -15,7 +15,7 @@ import ( ) func TestSearchService_Repositories(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/search/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -48,7 +48,7 @@ func TestSearchService_Repositories(t *testing.T) { } func TestSearchService_Commits(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/search/commits", func(w http.ResponseWriter, r *http.Request) { @@ -79,7 +79,7 @@ func TestSearchService_Commits(t *testing.T) { } func TestSearchService_Issues(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) { @@ -112,7 +112,7 @@ func TestSearchService_Issues(t *testing.T) { } func TestSearchService_Issues_withQualifiers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) { @@ -141,7 +141,7 @@ func TestSearchService_Issues_withQualifiers(t *testing.T) { } func TestSearchService_Users(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/search/users", func(w http.ResponseWriter, r *http.Request) { @@ -174,7 +174,7 @@ func TestSearchService_Users(t *testing.T) { } func TestSearchService_Code(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/search/code", func(w http.ResponseWriter, r *http.Request) { @@ -207,7 +207,7 @@ func TestSearchService_Code(t *testing.T) { } func TestSearchService_CodeTextMatch(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/search/code", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_administration_test.go b/github/users_administration_test.go index 8f02b88cea7..1ea5d55c65c 100644 --- a/github/users_administration_test.go +++ b/github/users_administration_test.go @@ -12,7 +12,7 @@ import ( ) func TestUsersService_PromoteSiteAdmin(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/site_admin", func(w http.ResponseWriter, r *http.Request) { @@ -27,7 +27,7 @@ func TestUsersService_PromoteSiteAdmin(t *testing.T) { } func TestUsersService_DemoteSiteAdmin(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/site_admin", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestUsersService_DemoteSiteAdmin(t *testing.T) { } func TestUsersService_Suspend(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestUsersService_Suspend(t *testing.T) { } func TestUsersService_Unsuspend(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_blocking_test.go b/github/users_blocking_test.go index ea7a8abdc23..c5192502c30 100644 --- a/github/users_blocking_test.go +++ b/github/users_blocking_test.go @@ -14,7 +14,7 @@ import ( ) func TestUsersService_ListBlockedUsers(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestUsersService_ListBlockedUsers(t *testing.T) { } func TestUsersService_IsBlocked(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestUsersService_IsBlocked(t *testing.T) { } func TestUsersService_BlockUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func TestUsersService_BlockUser(t *testing.T) { } func TestUsersService_UnblockUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_emails_test.go b/github/users_emails_test.go index 3f8176a0078..1be1cb589c5 100644 --- a/github/users_emails_test.go +++ b/github/users_emails_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListEmails(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/emails", func(w http.ResponseWriter, r *http.Request) { @@ -41,7 +41,7 @@ func TestUsersService_ListEmails(t *testing.T) { } func TestUsersService_AddEmails(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := []string{"new@example.com"} @@ -73,7 +73,7 @@ func TestUsersService_AddEmails(t *testing.T) { } func TestUsersService_DeleteEmails(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := []string{"user@example.com"} diff --git a/github/users_followers_test.go b/github/users_followers_test.go index 688af2c4450..69e8493d75a 100644 --- a/github/users_followers_test.go +++ b/github/users_followers_test.go @@ -14,7 +14,7 @@ import ( ) func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/followers", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) { } func TestUsersService_ListFollowers_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/followers", func(w http.ResponseWriter, r *http.Request) { @@ -56,12 +56,15 @@ func TestUsersService_ListFollowers_specifiedUser(t *testing.T) { } func TestUsersService_ListFollowers_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Users.ListFollowers(context.Background(), "%", nil) testURLParseError(t, err) } func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/following", func(w http.ResponseWriter, r *http.Request) { @@ -83,7 +86,7 @@ func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) { } func TestUsersService_ListFollowing_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following", func(w http.ResponseWriter, r *http.Request) { @@ -103,12 +106,15 @@ func TestUsersService_ListFollowing_specifiedUser(t *testing.T) { } func TestUsersService_ListFollowing_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Users.ListFollowing(context.Background(), "%", nil) testURLParseError(t, err) } func TestUsersService_IsFollowing_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -126,7 +132,7 @@ func TestUsersService_IsFollowing_authenticatedUser(t *testing.T) { } func TestUsersService_IsFollowing_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -144,7 +150,7 @@ func TestUsersService_IsFollowing_specifiedUser(t *testing.T) { } func TestUsersService_IsFollowing_false(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -162,7 +168,7 @@ func TestUsersService_IsFollowing_false(t *testing.T) { } func TestUsersService_IsFollowing_error(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -180,12 +186,15 @@ func TestUsersService_IsFollowing_error(t *testing.T) { } func TestUsersService_IsFollowing_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Users.IsFollowing(context.Background(), "%", "%") testURLParseError(t, err) } func TestUsersService_Follow(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) { @@ -199,12 +208,15 @@ func TestUsersService_Follow(t *testing.T) { } func TestUsersService_Follow_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Users.Follow(context.Background(), "%") testURLParseError(t, err) } func TestUsersService_Unfollow(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) { @@ -218,6 +230,9 @@ func TestUsersService_Unfollow(t *testing.T) { } func TestUsersService_Unfollow_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, err := client.Users.Unfollow(context.Background(), "%") testURLParseError(t, err) } diff --git a/github/users_gpg_keys_test.go b/github/users_gpg_keys_test.go index f4180df9881..93bbab68c9c 100644 --- a/github/users_gpg_keys_test.go +++ b/github/users_gpg_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListGPGKeys_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestUsersService_ListGPGKeys_authenticatedUser(t *testing.T) { } func TestUsersService_ListGPGKeys_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/gpg_keys", func(w http.ResponseWriter, r *http.Request) { @@ -59,12 +59,15 @@ func TestUsersService_ListGPGKeys_specifiedUser(t *testing.T) { } func TestUsersService_ListGPGKeys_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Users.ListGPGKeys(context.Background(), "%", nil) testURLParseError(t, err) } func TestUsersService_GetGPGKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -85,7 +88,7 @@ func TestUsersService_GetGPGKey(t *testing.T) { } func TestUsersService_CreateGPGKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := ` @@ -124,7 +127,7 @@ mQINBFcEd9kBEACo54TDbGhKlXKWMvJgecEUKPPcv7XdnpKdGb3LRw5MvFwT0V0f } func TestUsersService_DeleteGPGKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_keys_test.go b/github/users_keys_test.go index 8554c50cd92..349c9fd9849 100644 --- a/github/users_keys_test.go +++ b/github/users_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/keys", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { } func TestUsersService_ListKeys_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/keys", func(w http.ResponseWriter, r *http.Request) { @@ -57,12 +57,15 @@ func TestUsersService_ListKeys_specifiedUser(t *testing.T) { } func TestUsersService_ListKeys_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Users.ListKeys(context.Background(), "%", nil) testURLParseError(t, err) } func TestUsersService_GetKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -82,7 +85,7 @@ func TestUsersService_GetKey(t *testing.T) { } func TestUsersService_CreateKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -111,7 +114,7 @@ func TestUsersService_CreateKey(t *testing.T) { } func TestUsersService_DeleteKey(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_test.go b/github/users_test.go index 34c239a6666..5b5d48b6303 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -57,7 +57,7 @@ func TestUser_marshall(t *testing.T) { } func TestUsersService_Get_authenticatedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) { @@ -77,7 +77,7 @@ func TestUsersService_Get_authenticatedUser(t *testing.T) { } func TestUsersService_Get_specifiedUser(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users/u", func(w http.ResponseWriter, r *http.Request) { @@ -97,12 +97,15 @@ func TestUsersService_Get_specifiedUser(t *testing.T) { } func TestUsersService_Get_invalidUser(t *testing.T) { + client, teardown := setup() + defer teardown() + _, _, err := client.Users.Get(context.Background(), "%") testURLParseError(t, err) } func TestUsersService_GetByID(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/1", func(w http.ResponseWriter, r *http.Request) { @@ -122,7 +125,7 @@ func TestUsersService_GetByID(t *testing.T) { } func TestUsersService_Edit(t *testing.T) { - setup() + client, teardown := setup() defer teardown() input := &User{Name: String("n")} @@ -151,7 +154,7 @@ func TestUsersService_Edit(t *testing.T) { } func TestUsersService_ListAll(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) { @@ -173,7 +176,7 @@ func TestUsersService_ListAll(t *testing.T) { } func TestUsersService_ListInvitations(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) { @@ -194,7 +197,7 @@ func TestUsersService_ListInvitations(t *testing.T) { } func TestUsersService_ListInvitations_withOptions(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) { @@ -212,7 +215,7 @@ func TestUsersService_ListInvitations_withOptions(t *testing.T) { } } func TestUsersService_AcceptInvitation(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) { @@ -227,7 +230,7 @@ func TestUsersService_AcceptInvitation(t *testing.T) { } func TestUsersService_DeclineInvitation(t *testing.T) { - setup() + client, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) { From f749b0ea1fb4dd7d71e3c9b1b4aee66419f155c3 Mon Sep 17 00:00:00 2001 From: Chris King Date: Sat, 28 Oct 2017 23:20:04 +0200 Subject: [PATCH 02/13] removes mux and server from global package scope --- CONTRIBUTING.md | 2 +- github/activity_events_test.go | 32 +++++----- github/activity_notifications_test.go | 18 +++--- github/activity_star_test.go | 22 +++---- github/activity_test.go | 2 +- github/activity_watching_test.go | 16 ++--- github/admin_test.go | 4 +- github/apps_installation_test.go | 6 +- github/apps_test.go | 2 +- github/authorizations_test.go | 32 +++++----- github/gists_comments_test.go | 20 +++--- github/gists_test.go | 52 +++++++-------- github/git_blobs_test.go | 8 +-- github/git_commits_test.go | 8 +-- github/git_refs_test.go | 20 +++--- github/git_tags_test.go | 4 +- github/git_trees_test.go | 10 +-- github/github_test.go | 44 ++++++------- github/gitignore_test.go | 6 +- github/issues_assignees_test.go | 16 ++--- github/issues_comments_test.go | 22 +++---- github/issues_events_test.go | 6 +- github/issues_labels_test.go | 44 ++++++------- github/issues_milestones_test.go | 20 +++--- github/issues_test.go | 28 ++++---- github/issues_timeline_test.go | 2 +- github/licenses_test.go | 6 +- github/migrations_source_import_test.go | 16 ++--- github/migrations_test.go | 12 ++-- github/misc_test.go | 16 ++--- github/orgs_hooks_test.go | 18 +++--- github/orgs_members_test.go | 40 ++++++------ github/orgs_outside_collaborators_test.go | 4 +- github/orgs_projects_test.go | 4 +- github/orgs_teams_test.go | 62 +++++++++--------- github/orgs_test.go | 18 +++--- github/orgs_users_blocking_test.go | 8 +-- github/projects_test.go | 30 ++++----- github/pulls_comments_test.go | 22 +++---- github/pulls_reviewers_test.go | 8 +-- github/pulls_reviews_test.go | 30 ++++----- github/pulls_test.go | 36 +++++------ github/reactions_test.go | 18 +++--- github/repos_collaborators_test.go | 22 +++---- github/repos_comments_test.go | 24 +++---- github/repos_commits_test.go | 8 +-- github/repos_community_health_test.go | 2 +- github/repos_contents_test.go | 28 ++++---- github/repos_deployments_test.go | 12 ++-- github/repos_forks_test.go | 8 +-- github/repos_hooks_test.go | 26 ++++---- github/repos_invitations_test.go | 6 +- github/repos_keys_test.go | 20 +++--- github/repos_merging_test.go | 2 +- github/repos_pages_test.go | 12 ++-- github/repos_projects_test.go | 4 +- github/repos_releases_test.go | 30 ++++----- github/repos_stats_test.go | 10 +-- github/repos_statuses_test.go | 10 +-- github/repos_test.go | 78 +++++++++++------------ github/repos_traffic_test.go | 8 +-- github/search_test.go | 14 ++-- github/users_administration_test.go | 8 +-- github/users_blocking_test.go | 8 +-- github/users_emails_test.go | 6 +- github/users_followers_test.go | 30 ++++----- github/users_gpg_keys_test.go | 12 ++-- github/users_keys_test.go | 12 ++-- github/users_test.go | 20 +++--- test/integration/doc.go | 2 +- 70 files changed, 604 insertions(+), 612 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68a23f00512..efefdc54713 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ again. issue that you are planning to work on that bug or feature so that it can be assigned to you. - 1. Follow the normal process of [forking][] the project, and setup a new + 1. Follow the normal process of [forking][] the project, and setup() a new branch to work in. It's important that each group of changes be done in separate branches in order to ensure that a pull request only includes the commits related to that bug or feature. diff --git a/github/activity_events_test.go b/github/activity_events_test.go index bc147835d9a..923454839d5 100644 --- a/github/activity_events_test.go +++ b/github/activity_events_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListEvents(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestActivityService_ListEvents(t *testing.T) { } func TestActivityService_ListRepositoryEvents(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/events", func(w http.ResponseWriter, r *http.Request) { @@ -63,7 +63,7 @@ func TestActivityService_ListRepositoryEvents(t *testing.T) { } func TestActivityService_ListRepositoryEvents_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Activity.ListRepositoryEvents(context.Background(), "%", "%", nil) @@ -71,7 +71,7 @@ func TestActivityService_ListRepositoryEvents_invalidOwner(t *testing.T) { } func TestActivityService_ListIssueEventsForRepository(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events", func(w http.ResponseWriter, r *http.Request) { @@ -95,7 +95,7 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) { } func TestActivityService_ListIssueEventsForRepository_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Activity.ListIssueEventsForRepository(context.Background(), "%", "%", nil) @@ -103,7 +103,7 @@ func TestActivityService_ListIssueEventsForRepository_invalidOwner(t *testing.T) } func TestActivityService_ListEventsForRepoNetwork(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/networks/o/r/events", func(w http.ResponseWriter, r *http.Request) { @@ -127,7 +127,7 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) { } func TestActivityService_ListEventsForRepoNetwork_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Activity.ListEventsForRepoNetwork(context.Background(), "%", "%", nil) @@ -135,7 +135,7 @@ func TestActivityService_ListEventsForRepoNetwork_invalidOwner(t *testing.T) { } func TestActivityService_ListEventsForOrganization(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/events", func(w http.ResponseWriter, r *http.Request) { @@ -159,7 +159,7 @@ func TestActivityService_ListEventsForOrganization(t *testing.T) { } func TestActivityService_ListEventsForOrganization_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Activity.ListEventsForOrganization(context.Background(), "%", nil) @@ -167,7 +167,7 @@ func TestActivityService_ListEventsForOrganization_invalidOrg(t *testing.T) { } func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events", func(w http.ResponseWriter, r *http.Request) { @@ -191,7 +191,7 @@ func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) { } func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events/public", func(w http.ResponseWriter, r *http.Request) { @@ -211,7 +211,7 @@ func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) { } func TestActivityService_ListEventsPerformedByUser_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Activity.ListEventsPerformedByUser(context.Background(), "%", false, nil) @@ -219,7 +219,7 @@ func TestActivityService_ListEventsPerformedByUser_invalidUser(t *testing.T) { } func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/received_events", func(w http.ResponseWriter, r *http.Request) { @@ -243,7 +243,7 @@ func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) { } func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/received_events/public", func(w http.ResponseWriter, r *http.Request) { @@ -263,7 +263,7 @@ func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) { } func TestActivityService_ListEventsReceivedByUser_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Activity.ListEventsReceivedByUser(context.Background(), "%", false, nil) @@ -271,7 +271,7 @@ func TestActivityService_ListEventsReceivedByUser_invalidUser(t *testing.T) { } func TestActivityService_ListUserEventsForOrganization(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events/orgs/o", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index ed04901aff5..47d230369b4 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -16,7 +16,7 @@ import ( ) func TestActivityService_ListNotification(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestActivityService_ListNotification(t *testing.T) { } func TestActivityService_ListRepositoryNotification(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestActivityService_ListRepositoryNotification(t *testing.T) { } func TestActivityService_MarkNotificationsRead(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -87,7 +87,7 @@ func TestActivityService_MarkNotificationsRead(t *testing.T) { } func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { } func TestActivityService_GetThread(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestActivityService_GetThread(t *testing.T) { } func TestActivityService_MarkThreadRead(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) { @@ -140,7 +140,7 @@ func TestActivityService_MarkThreadRead(t *testing.T) { } func TestActivityService_GetThreadSubscription(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -160,7 +160,7 @@ func TestActivityService_GetThreadSubscription(t *testing.T) { } func TestActivityService_SetThreadSubscription(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Subscription{Subscribed: Bool(true)} @@ -189,7 +189,7 @@ func TestActivityService_SetThreadSubscription(t *testing.T) { } func TestActivityService_DeleteThreadSubscription(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_star_test.go b/github/activity_star_test.go index cfbac41ff1a..952e8bc8552 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListStargazers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stargazers", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestActivityService_ListStargazers(t *testing.T) { } func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred", func(w http.ResponseWriter, r *http.Request) { @@ -61,7 +61,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { } func TestActivityService_ListStarred_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/starred", func(w http.ResponseWriter, r *http.Request) { @@ -88,7 +88,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) { } func TestActivityService_ListStarred_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Activity.ListStarred(context.Background(), "%", nil) @@ -96,7 +96,7 @@ func TestActivityService_ListStarred_invalidUser(t *testing.T) { } func TestActivityService_IsStarred_hasStar(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -114,7 +114,7 @@ func TestActivityService_IsStarred_hasStar(t *testing.T) { } func TestActivityService_IsStarred_noStar(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -132,7 +132,7 @@ func TestActivityService_IsStarred_noStar(t *testing.T) { } func TestActivityService_IsStarred_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Activity.IsStarred(context.Background(), "%", "%") @@ -140,7 +140,7 @@ func TestActivityService_IsStarred_invalidID(t *testing.T) { } func TestActivityService_Star(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -154,7 +154,7 @@ func TestActivityService_Star(t *testing.T) { } func TestActivityService_Star_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Activity.Star(context.Background(), "%", "%") @@ -162,7 +162,7 @@ func TestActivityService_Star_invalidID(t *testing.T) { } func TestActivityService_Unstar(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -176,7 +176,7 @@ func TestActivityService_Unstar(t *testing.T) { } func TestActivityService_Unstar_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Activity.Unstar(context.Background(), "%", "%") diff --git a/github/activity_test.go b/github/activity_test.go index bf240984b45..a47b074cfc4 100644 --- a/github/activity_test.go +++ b/github/activity_test.go @@ -13,7 +13,7 @@ import ( ) func TestActivityService_List(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/feeds", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index db2596d15fb..c353f8ac896 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListWatchers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscribers", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestActivityService_ListWatchers(t *testing.T) { } func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/subscriptions", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { } func TestActivityService_ListWatched_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/subscriptions", func(w http.ResponseWriter, r *http.Request) { @@ -85,7 +85,7 @@ func TestActivityService_ListWatched_specifiedUser(t *testing.T) { } func TestActivityService_GetRepositorySubscription_true(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestActivityService_GetRepositorySubscription_true(t *testing.T) { } func TestActivityService_GetRepositorySubscription_false(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestActivityService_GetRepositorySubscription_false(t *testing.T) { } func TestActivityService_GetRepositorySubscription_error(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -140,7 +140,7 @@ func TestActivityService_GetRepositorySubscription_error(t *testing.T) { } func TestActivityService_SetRepositorySubscription(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Subscription{Subscribed: Bool(true)} @@ -169,7 +169,7 @@ func TestActivityService_SetRepositorySubscription(t *testing.T) { } func TestActivityService_DeleteRepositorySubscription(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/admin_test.go b/github/admin_test.go index aeb40830321..10f3bec26f1 100644 --- a/github/admin_test.go +++ b/github/admin_test.go @@ -15,7 +15,7 @@ import ( ) func TestAdminService_UpdateUserLDAPMapping(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &UserLDAPMapping{ @@ -48,7 +48,7 @@ func TestAdminService_UpdateUserLDAPMapping(t *testing.T) { } func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &TeamLDAPMapping{ diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index 1dcbb20c933..9937f8e66f9 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -14,7 +14,7 @@ import ( ) func TestAppsService_ListRepos(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/installation/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestAppsService_ListRepos(t *testing.T) { } func TestAppsService_AddRepository(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/apps/installations/1/repositories/1", func(w http.ResponseWriter, r *http.Request) { @@ -60,7 +60,7 @@ func TestAppsService_AddRepository(t *testing.T) { } func TestAppsService_RemoveRepository(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/apps/installations/1/repositories/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/apps_test.go b/github/apps_test.go index a7b858c698b..3d1deb6ec4d 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -14,7 +14,7 @@ import ( ) func TestAppsService_ListInstallations(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/app/installations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/authorizations_test.go b/github/authorizations_test.go index 1a33bb2e0af..58c9738fd12 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -15,7 +15,7 @@ import ( ) func TestAuthorizationsService_List(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/authorizations", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestAuthorizationsService_List(t *testing.T) { } func TestAuthorizationsService_Get(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestAuthorizationsService_Get(t *testing.T) { } func TestAuthorizationsService_Create(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -88,7 +88,7 @@ func TestAuthorizationsService_Create(t *testing.T) { } func TestAuthorizationsService_GetOrCreateForApp(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -119,7 +119,7 @@ func TestAuthorizationsService_GetOrCreateForApp(t *testing.T) { } func TestAuthorizationsService_GetOrCreateForApp_Fingerprint(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -151,7 +151,7 @@ func TestAuthorizationsService_GetOrCreateForApp_Fingerprint(t *testing.T) { } func TestAuthorizationsService_Edit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &AuthorizationUpdateRequest{ @@ -182,7 +182,7 @@ func TestAuthorizationsService_Edit(t *testing.T) { } func TestAuthorizationsService_Delete(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -197,7 +197,7 @@ func TestAuthorizationsService_Delete(t *testing.T) { } func TestAuthorizationsService_Check(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -217,7 +217,7 @@ func TestAuthorizationsService_Check(t *testing.T) { } func TestAuthorizationsService_Reset(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -237,7 +237,7 @@ func TestAuthorizationsService_Reset(t *testing.T) { } func TestAuthorizationsService_Revoke(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -252,7 +252,7 @@ func TestAuthorizationsService_Revoke(t *testing.T) { } func TestListGrants(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) { @@ -272,7 +272,7 @@ func TestListGrants(t *testing.T) { } func TestListGrants_withOptions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) { @@ -290,7 +290,7 @@ func TestListGrants_withOptions(t *testing.T) { } func TestGetGrant(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) { @@ -310,7 +310,7 @@ func TestGetGrant(t *testing.T) { } func TestDeleteGrant(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) { @@ -324,7 +324,7 @@ func TestDeleteGrant(t *testing.T) { } func TestAuthorizationsService_CreateImpersonation(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) { @@ -345,7 +345,7 @@ func TestAuthorizationsService_CreateImpersonation(t *testing.T) { } func TestAuthorizationsService_DeleteImpersonation(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/gists_comments_test.go b/github/gists_comments_test.go index 05857dc60dc..7952e110d34 100644 --- a/github/gists_comments_test.go +++ b/github/gists_comments_test.go @@ -15,7 +15,7 @@ import ( ) func TestGistsService_ListComments(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestGistsService_ListComments(t *testing.T) { } func TestGistsService_ListComments_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.ListComments(context.Background(), "%", nil) @@ -45,7 +45,7 @@ func TestGistsService_ListComments_invalidID(t *testing.T) { } func TestGistsService_GetComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func TestGistsService_GetComment(t *testing.T) { } func TestGistsService_GetComment_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.GetComment(context.Background(), "%", 1) @@ -73,7 +73,7 @@ func TestGistsService_GetComment_invalidID(t *testing.T) { } func TestGistsService_CreateComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &GistComment{ID: Int(1), Body: String("b")} @@ -102,7 +102,7 @@ func TestGistsService_CreateComment(t *testing.T) { } func TestGistsService_CreateComment_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.CreateComment(context.Background(), "%", nil) @@ -110,7 +110,7 @@ func TestGistsService_CreateComment_invalidID(t *testing.T) { } func TestGistsService_EditComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &GistComment{ID: Int(1), Body: String("b")} @@ -139,7 +139,7 @@ func TestGistsService_EditComment(t *testing.T) { } func TestGistsService_EditComment_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.EditComment(context.Background(), "%", 1, nil) @@ -147,7 +147,7 @@ func TestGistsService_EditComment_invalidID(t *testing.T) { } func TestGistsService_DeleteComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) { @@ -161,7 +161,7 @@ func TestGistsService_DeleteComment(t *testing.T) { } func TestGistsService_DeleteComment_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Gists.DeleteComment(context.Background(), "%", 1) diff --git a/github/gists_test.go b/github/gists_test.go index cb2eee25fef..4c76d436e1b 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -16,7 +16,7 @@ import ( ) func TestGistsService_List_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -42,7 +42,7 @@ func TestGistsService_List_specifiedUser(t *testing.T) { } func TestGistsService_List_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestGistsService_List_authenticatedUser(t *testing.T) { } func TestGistsService_List_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.List(context.Background(), "%", nil) @@ -70,7 +70,7 @@ func TestGistsService_List_invalidUser(t *testing.T) { } func TestGistsService_ListAll(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -96,7 +96,7 @@ func TestGistsService_ListAll(t *testing.T) { } func TestGistsService_ListStarred(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -122,7 +122,7 @@ func TestGistsService_ListStarred(t *testing.T) { } func TestGistsService_Get(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) { @@ -142,7 +142,7 @@ func TestGistsService_Get(t *testing.T) { } func TestGistsService_Get_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.Get(context.Background(), "%") @@ -150,7 +150,7 @@ func TestGistsService_Get_invalidID(t *testing.T) { } func TestGistsService_GetRevision(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/s", func(w http.ResponseWriter, r *http.Request) { @@ -170,7 +170,7 @@ func TestGistsService_GetRevision(t *testing.T) { } func TestGistsService_GetRevision_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.GetRevision(context.Background(), "%", "%") @@ -178,7 +178,7 @@ func TestGistsService_GetRevision_invalidID(t *testing.T) { } func TestGistsService_Create(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Gist{ @@ -231,7 +231,7 @@ func TestGistsService_Create(t *testing.T) { } func TestGistsService_Edit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Gist{ @@ -287,7 +287,7 @@ func TestGistsService_Edit(t *testing.T) { } func TestGistsService_Edit_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.Edit(context.Background(), "%", nil) @@ -295,7 +295,7 @@ func TestGistsService_Edit_invalidID(t *testing.T) { } func TestGistsService_ListCommits(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -342,7 +342,7 @@ func TestGistsService_ListCommits(t *testing.T) { } func TestGistsService_ListCommits_withOptions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -360,7 +360,7 @@ func TestGistsService_ListCommits_withOptions(t *testing.T) { } func TestGistsService_Delete(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) { @@ -374,7 +374,7 @@ func TestGistsService_Delete(t *testing.T) { } func TestGistsService_Delete_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Gists.Delete(context.Background(), "%") @@ -382,7 +382,7 @@ func TestGistsService_Delete_invalidID(t *testing.T) { } func TestGistsService_Star(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -396,7 +396,7 @@ func TestGistsService_Star(t *testing.T) { } func TestGistsService_Star_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Gists.Star(context.Background(), "%") @@ -404,7 +404,7 @@ func TestGistsService_Star_invalidID(t *testing.T) { } func TestGistsService_Unstar(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -418,7 +418,7 @@ func TestGistsService_Unstar(t *testing.T) { } func TestGistsService_Unstar_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Gists.Unstar(context.Background(), "%") @@ -426,7 +426,7 @@ func TestGistsService_Unstar_invalidID(t *testing.T) { } func TestGistsService_IsStarred_hasStar(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -444,7 +444,7 @@ func TestGistsService_IsStarred_hasStar(t *testing.T) { } func TestGistsService_IsStarred_noStar(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -462,7 +462,7 @@ func TestGistsService_IsStarred_noStar(t *testing.T) { } func TestGistsService_IsStarred_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.IsStarred(context.Background(), "%") @@ -470,7 +470,7 @@ func TestGistsService_IsStarred_invalidID(t *testing.T) { } func TestGistsService_Fork(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) { @@ -490,7 +490,7 @@ func TestGistsService_Fork(t *testing.T) { } func TestGistsService_ListForks(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) { @@ -526,7 +526,7 @@ func TestGistsService_ListForks(t *testing.T) { } func TestGistsService_Fork_invalidID(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gists.Fork(context.Background(), "%") diff --git a/github/git_blobs_test.go b/github/git_blobs_test.go index 6e30cf09a0f..a199021fc78 100644 --- a/github/git_blobs_test.go +++ b/github/git_blobs_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetBlob(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/blobs/s", func(w http.ResponseWriter, r *http.Request) { @@ -44,7 +44,7 @@ func TestGitService_GetBlob(t *testing.T) { } func TestGitService_GetBlob_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Git.GetBlob(context.Background(), "%", "%", "%") @@ -52,7 +52,7 @@ func TestGitService_GetBlob_invalidOwner(t *testing.T) { } func TestGitService_CreateBlob(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Blob{ @@ -96,7 +96,7 @@ func TestGitService_CreateBlob(t *testing.T) { } func TestGitService_CreateBlob_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Git.CreateBlob(context.Background(), "%", "%", &Blob{}) diff --git a/github/git_commits_test.go b/github/git_commits_test.go index c70a05c0f6b..ecf45e4f871 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetCommit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/commits/s", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestGitService_GetCommit(t *testing.T) { } func TestGitService_GetCommit_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Git.GetCommit(context.Background(), "%", "%", "%") @@ -44,7 +44,7 @@ func TestGitService_GetCommit_invalidOwner(t *testing.T) { } func TestGitService_CreateCommit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Commit{ @@ -82,7 +82,7 @@ func TestGitService_CreateCommit(t *testing.T) { } func TestGitService_CreateCommit_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Git.CreateCommit(context.Background(), "%", "%", &Commit{}) diff --git a/github/git_refs_test.go b/github/git_refs_test.go index 55aa659e356..0e8efce5545 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetRef_singleRef(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestGitService_GetRef_singleRef(t *testing.T) { } func TestGitService_GetRef_multipleRefs(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -95,7 +95,7 @@ func TestGitService_GetRef_multipleRefs(t *testing.T) { } func TestGitService_GetRefs_singleRef(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -138,7 +138,7 @@ func TestGitService_GetRefs_singleRef(t *testing.T) { } func TestGitService_GetRefs_multipleRefs(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -188,7 +188,7 @@ func TestGitService_GetRefs_multipleRefs(t *testing.T) { // TestGitService_GetRefs_noRefs tests for behaviour resulting from an unexpected GH response. This should never actually happen. func TestGitService_GetRefs_noRefs(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -205,7 +205,7 @@ func TestGitService_GetRefs_noRefs(t *testing.T) { } func TestGitService_ListRefs(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs", func(w http.ResponseWriter, r *http.Request) { @@ -264,7 +264,7 @@ func TestGitService_ListRefs(t *testing.T) { } func TestGitService_ListRefs_options(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/t", func(w http.ResponseWriter, r *http.Request) { @@ -286,7 +286,7 @@ func TestGitService_ListRefs_options(t *testing.T) { } func TestGitService_CreateRef(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() args := &createRefRequest{ @@ -350,7 +350,7 @@ func TestGitService_CreateRef(t *testing.T) { } func TestGitService_UpdateRef(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() args := &updateRefRequest{ @@ -410,7 +410,7 @@ func TestGitService_UpdateRef(t *testing.T) { } func TestGitService_DeleteRef(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/git_tags_test.go b/github/git_tags_test.go index e9c06efb2a0..5b591951404 100644 --- a/github/git_tags_test.go +++ b/github/git_tags_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetTag(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/tags/s", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestGitService_GetTag(t *testing.T) { } func TestGitService_CreateTag(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &createTagRequest{Tag: String("t"), Object: String("s")} diff --git a/github/git_trees_test.go b/github/git_trees_test.go index 492359a0c26..9f733e63a8c 100644 --- a/github/git_trees_test.go +++ b/github/git_trees_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetTree(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/trees/s", func(w http.ResponseWriter, r *http.Request) { @@ -47,7 +47,7 @@ func TestGitService_GetTree(t *testing.T) { } func TestGitService_GetTree_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Git.GetTree(context.Background(), "%", "%", "%", false) @@ -55,7 +55,7 @@ func TestGitService_GetTree_invalidOwner(t *testing.T) { } func TestGitService_CreateTree(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := []TreeEntry{ @@ -121,7 +121,7 @@ func TestGitService_CreateTree(t *testing.T) { } func TestGitService_CreateTree_Content(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := []TreeEntry{ @@ -189,7 +189,7 @@ func TestGitService_CreateTree_Content(t *testing.T) { } func TestGitService_CreateTree_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Git.CreateTree(context.Background(), "%", "%", "", nil) diff --git a/github/github_test.go b/github/github_test.go index 2d9390427bd..c20f7bc8e66 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -22,26 +22,18 @@ import ( "time" ) -var ( - // mux is the HTTP request multiplexer used with the test server. - mux *http.ServeMux - - // server is a test HTTP server used to provide mock API responses. - server *httptest.Server -) - const ( // baseURLPath is a non-empty Client.BaseURL path to use during tests, // to ensure relative URLs are used for all endpoints. See issue #752. baseURLPath = "/api-v3" ) -// setup sets up a test HTTP server along with a github.Client that is +// setup() sets up a test HTTP server along with a github.Client that is // configured to talk to that test server. Tests should register handlers on // mux which provide mock responses for the API method being tested. -func setup() (*Client, func()) { +func setup() (string, *http.ServeMux, *Client, func()) { // test server - mux = http.NewServeMux() + mux := http.NewServeMux() // We want to ensure that tests catch mistakes where the endpoint URL is // specified as absolute rather than relative. It only makes a difference @@ -58,7 +50,7 @@ func setup() (*Client, func()) { http.Error(w, "Client.BaseURL path prefix is not preserved in the request URL.", http.StatusInternalServerError) }) - server = httptest.NewServer(apiHandler) + server := httptest.NewServer(apiHandler) // github client configured to use test server client := NewClient(nil) @@ -66,7 +58,7 @@ func setup() (*Client, func()) { client.BaseURL = url client.UploadURL = url - return client, server.Close + return server.URL, mux, client, server.Close } // openTestFile creates a new file with the given name and content for testing. @@ -376,7 +368,7 @@ func TestResponse_populatePageValues_invalid(t *testing.T) { } func TestDo(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() type foo struct { @@ -401,7 +393,7 @@ func TestDo(t *testing.T) { } func TestDo_httpError(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -423,7 +415,7 @@ func TestDo_httpError(t *testing.T) { // function. A redirect loop is pretty unlikely to occur within the GitHub // API, but does allow us to exercise the right code path. func TestDo_redirectLoop(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -464,7 +456,7 @@ func TestDo_sanitizeURL(t *testing.T) { } func TestDo_rateLimit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -492,7 +484,7 @@ func TestDo_rateLimit(t *testing.T) { // ensure rate limit is still parsed, even for error responses func TestDo_rateLimit_errorResponse(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -524,7 +516,7 @@ func TestDo_rateLimit_errorResponse(t *testing.T) { // Ensure *RateLimitError is returned when API rate limit is exceeded. func TestDo_rateLimit_rateLimitError(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -563,7 +555,7 @@ func TestDo_rateLimit_rateLimitError(t *testing.T) { // Ensure a network call is not made when it's known that API rate limit is still exceeded. func TestDo_rateLimit_noNetworkCall(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() reset := time.Now().UTC().Add(time.Minute).Round(time.Second) // Rate reset is a minute from now, with 1 second precision. @@ -618,7 +610,7 @@ func TestDo_rateLimit_noNetworkCall(t *testing.T) { // Ensure *AbuseRateLimitError is returned when the response indicates that // the client has triggered an abuse detection mechanism. func TestDo_rateLimit_abuseRateLimitError(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -649,7 +641,7 @@ func TestDo_rateLimit_abuseRateLimitError(t *testing.T) { // Ensure *AbuseRateLimitError.RetryAfter is parsed correctly. func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -681,7 +673,7 @@ func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { } func TestDo_noContent(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -820,7 +812,7 @@ func TestError_Error(t *testing.T) { } func TestRateLimits(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) { @@ -863,7 +855,7 @@ func TestRateLimits(t *testing.T) { } func TestUnauthenticatedRateLimitedTransport(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -929,7 +921,7 @@ func TestUnauthenticatedRateLimitedTransport_transport(t *testing.T) { } func TestBasicAuthTransport(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() username, password, otp := "u", "p", "123456" diff --git a/github/gitignore_test.go b/github/gitignore_test.go index 07a2e301101..aac37bd0a34 100644 --- a/github/gitignore_test.go +++ b/github/gitignore_test.go @@ -14,7 +14,7 @@ import ( ) func TestGitignoresService_List(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gitignore/templates", func(w http.ResponseWriter, r *http.Request) { @@ -34,7 +34,7 @@ func TestGitignoresService_List(t *testing.T) { } func TestGitignoresService_Get(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/gitignore/templates/name", func(w http.ResponseWriter, r *http.Request) { @@ -54,7 +54,7 @@ func TestGitignoresService_Get(t *testing.T) { } func TestGitignoresService_Get_invalidTemplate(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Gitignores.Get(context.Background(), "%") diff --git a/github/issues_assignees_test.go b/github/issues_assignees_test.go index 474d98fa0c9..ddc7ddaa4f9 100644 --- a/github/issues_assignees_test.go +++ b/github/issues_assignees_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListAssignees(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestIssuesService_ListAssignees(t *testing.T) { } func TestIssuesService_ListAssignees_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ListAssignees(context.Background(), "%", "r", nil) @@ -45,7 +45,7 @@ func TestIssuesService_ListAssignees_invalidOwner(t *testing.T) { } func TestIssuesService_IsAssignee_true(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestIssuesService_IsAssignee_true(t *testing.T) { } func TestIssuesService_IsAssignee_false(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -80,7 +80,7 @@ func TestIssuesService_IsAssignee_false(t *testing.T) { } func TestIssuesService_IsAssignee_error(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func TestIssuesService_IsAssignee_error(t *testing.T) { } func TestIssuesService_IsAssignee_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.IsAssignee(context.Background(), "%", "r", "u") @@ -106,7 +106,7 @@ func TestIssuesService_IsAssignee_invalidOwner(t *testing.T) { } func TestIssuesService_AddAssignees(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) { @@ -135,7 +135,7 @@ func TestIssuesService_AddAssignees(t *testing.T) { } func TestIssuesService_RemoveAssignees(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index 7661e88e9dc..573bd53861c 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -16,7 +16,7 @@ import ( ) func TestIssuesService_ListComments_allIssues(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) { } func TestIssuesService_ListComments_specificIssue(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestIssuesService_ListComments_specificIssue(t *testing.T) { } func TestIssuesService_ListComments_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ListComments(context.Background(), "%", "r", 1, nil) @@ -78,7 +78,7 @@ func TestIssuesService_ListComments_invalidOwner(t *testing.T) { } func TestIssuesService_GetComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -99,7 +99,7 @@ func TestIssuesService_GetComment(t *testing.T) { } func TestIssuesService_GetComment_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.GetComment(context.Background(), "%", "r", 1) @@ -107,7 +107,7 @@ func TestIssuesService_GetComment_invalidOrg(t *testing.T) { } func TestIssuesService_CreateComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &IssueComment{Body: String("b")} @@ -136,7 +136,7 @@ func TestIssuesService_CreateComment(t *testing.T) { } func TestIssuesService_CreateComment_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.CreateComment(context.Background(), "%", "r", 1, nil) @@ -144,7 +144,7 @@ func TestIssuesService_CreateComment_invalidOrg(t *testing.T) { } func TestIssuesService_EditComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &IssueComment{Body: String("b")} @@ -173,7 +173,7 @@ func TestIssuesService_EditComment(t *testing.T) { } func TestIssuesService_EditComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.EditComment(context.Background(), "%", "r", 1, nil) @@ -181,7 +181,7 @@ func TestIssuesService_EditComment_invalidOwner(t *testing.T) { } func TestIssuesService_DeleteComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -195,7 +195,7 @@ func TestIssuesService_DeleteComment(t *testing.T) { } func TestIssuesService_DeleteComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Issues.DeleteComment(context.Background(), "%", "r", 1) diff --git a/github/issues_events_test.go b/github/issues_events_test.go index 1acc5eed252..8dd82002a12 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -14,7 +14,7 @@ import ( ) func TestIssuesService_ListIssueEvents(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/events", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestIssuesService_ListIssueEvents(t *testing.T) { } func TestIssuesService_ListRepositoryEvents(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events", func(w http.ResponseWriter, r *http.Request) { @@ -64,7 +64,7 @@ func TestIssuesService_ListRepositoryEvents(t *testing.T) { } func TestIssuesService_GetEvent(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_labels_test.go b/github/issues_labels_test.go index 4bb84f297ec..0487263acc2 100644 --- a/github/issues_labels_test.go +++ b/github/issues_labels_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListLabels(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestIssuesService_ListLabels(t *testing.T) { } func TestIssuesService_ListLabels_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ListLabels(context.Background(), "%", "%", nil) @@ -45,7 +45,7 @@ func TestIssuesService_ListLabels_invalidOwner(t *testing.T) { } func TestIssuesService_GetLabel(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func TestIssuesService_GetLabel(t *testing.T) { } func TestIssuesService_GetLabel_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.GetLabel(context.Background(), "%", "%", "%") @@ -73,7 +73,7 @@ func TestIssuesService_GetLabel_invalidOwner(t *testing.T) { } func TestIssuesService_CreateLabel(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Label{Name: String("n")} @@ -102,7 +102,7 @@ func TestIssuesService_CreateLabel(t *testing.T) { } func TestIssuesService_CreateLabel_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.CreateLabel(context.Background(), "%", "%", nil) @@ -110,7 +110,7 @@ func TestIssuesService_CreateLabel_invalidOwner(t *testing.T) { } func TestIssuesService_EditLabel(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Label{Name: String("z")} @@ -139,7 +139,7 @@ func TestIssuesService_EditLabel(t *testing.T) { } func TestIssuesService_EditLabel_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.EditLabel(context.Background(), "%", "%", "%", nil) @@ -147,7 +147,7 @@ func TestIssuesService_EditLabel_invalidOwner(t *testing.T) { } func TestIssuesService_DeleteLabel(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) { @@ -161,7 +161,7 @@ func TestIssuesService_DeleteLabel(t *testing.T) { } func TestIssuesService_DeleteLabel_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Issues.DeleteLabel(context.Background(), "%", "%", "%") @@ -169,7 +169,7 @@ func TestIssuesService_DeleteLabel_invalidOwner(t *testing.T) { } func TestIssuesService_ListLabelsByIssue(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -194,7 +194,7 @@ func TestIssuesService_ListLabelsByIssue(t *testing.T) { } func TestIssuesService_ListLabelsByIssue_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ListLabelsByIssue(context.Background(), "%", "%", 1, nil) @@ -202,7 +202,7 @@ func TestIssuesService_ListLabelsByIssue_invalidOwner(t *testing.T) { } func TestIssuesService_AddLabelsToIssue(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := []string{"a", "b"} @@ -231,7 +231,7 @@ func TestIssuesService_AddLabelsToIssue(t *testing.T) { } func TestIssuesService_AddLabelsToIssue_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.AddLabelsToIssue(context.Background(), "%", "%", 1, nil) @@ -239,7 +239,7 @@ func TestIssuesService_AddLabelsToIssue_invalidOwner(t *testing.T) { } func TestIssuesService_RemoveLabelForIssue(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels/l", func(w http.ResponseWriter, r *http.Request) { @@ -253,7 +253,7 @@ func TestIssuesService_RemoveLabelForIssue(t *testing.T) { } func TestIssuesService_RemoveLabelForIssue_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Issues.RemoveLabelForIssue(context.Background(), "%", "%", 1, "%") @@ -261,7 +261,7 @@ func TestIssuesService_RemoveLabelForIssue_invalidOwner(t *testing.T) { } func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := []string{"a", "b"} @@ -290,7 +290,7 @@ func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) { } func TestIssuesService_ReplaceLabelsForIssue_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ReplaceLabelsForIssue(context.Background(), "%", "%", 1, nil) @@ -298,7 +298,7 @@ func TestIssuesService_ReplaceLabelsForIssue_invalidOwner(t *testing.T) { } func TestIssuesService_RemoveLabelsForIssue(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -312,7 +312,7 @@ func TestIssuesService_RemoveLabelsForIssue(t *testing.T) { } func TestIssuesService_RemoveLabelsForIssue_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Issues.RemoveLabelsForIssue(context.Background(), "%", "%", 1) @@ -320,7 +320,7 @@ func TestIssuesService_RemoveLabelsForIssue_invalidOwner(t *testing.T) { } func TestIssuesService_ListLabelsForMilestone(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -342,7 +342,7 @@ func TestIssuesService_ListLabelsForMilestone(t *testing.T) { } func TestIssuesService_ListLabelsForMilestone_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ListLabelsForMilestone(context.Background(), "%", "%", 1, nil) diff --git a/github/issues_milestones_test.go b/github/issues_milestones_test.go index 9145f96b11d..eb2e57dc025 100644 --- a/github/issues_milestones_test.go +++ b/github/issues_milestones_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListMilestones(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestIssuesService_ListMilestones(t *testing.T) { } func TestIssuesService_ListMilestones_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ListMilestones(context.Background(), "%", "r", nil) @@ -50,7 +50,7 @@ func TestIssuesService_ListMilestones_invalidOwner(t *testing.T) { } func TestIssuesService_GetMilestone(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestIssuesService_GetMilestone(t *testing.T) { } func TestIssuesService_GetMilestone_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.GetMilestone(context.Background(), "%", "r", 1) @@ -78,7 +78,7 @@ func TestIssuesService_GetMilestone_invalidOwner(t *testing.T) { } func TestIssuesService_CreateMilestone(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Milestone{Title: String("t")} @@ -107,7 +107,7 @@ func TestIssuesService_CreateMilestone(t *testing.T) { } func TestIssuesService_CreateMilestone_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.CreateMilestone(context.Background(), "%", "r", nil) @@ -115,7 +115,7 @@ func TestIssuesService_CreateMilestone_invalidOwner(t *testing.T) { } func TestIssuesService_EditMilestone(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Milestone{Title: String("t")} @@ -144,7 +144,7 @@ func TestIssuesService_EditMilestone(t *testing.T) { } func TestIssuesService_EditMilestone_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.EditMilestone(context.Background(), "%", "r", 1, nil) @@ -152,7 +152,7 @@ func TestIssuesService_EditMilestone_invalidOwner(t *testing.T) { } func TestIssuesService_DeleteMilestone(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) { @@ -166,7 +166,7 @@ func TestIssuesService_DeleteMilestone(t *testing.T) { } func TestIssuesService_DeleteMilestone_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Issues.DeleteMilestone(context.Background(), "%", "r", 1) diff --git a/github/issues_test.go b/github/issues_test.go index 06ce91c9806..55684a3c750 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -16,7 +16,7 @@ import ( ) func TestIssuesService_List_all(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/issues", func(w http.ResponseWriter, r *http.Request) { @@ -52,7 +52,7 @@ func TestIssuesService_List_all(t *testing.T) { } func TestIssuesService_List_owned(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/issues", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestIssuesService_List_owned(t *testing.T) { } func TestIssuesService_ListByOrg(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/issues", func(w http.ResponseWriter, r *http.Request) { @@ -94,7 +94,7 @@ func TestIssuesService_ListByOrg(t *testing.T) { } func TestIssuesService_ListByOrg_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ListByOrg(context.Background(), "%", nil) @@ -102,7 +102,7 @@ func TestIssuesService_ListByOrg_invalidOrg(t *testing.T) { } func TestIssuesService_ListByRepo(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues", func(w http.ResponseWriter, r *http.Request) { @@ -139,7 +139,7 @@ func TestIssuesService_ListByRepo(t *testing.T) { } func TestIssuesService_ListByRepo_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.ListByRepo(context.Background(), "%", "r", nil) @@ -147,7 +147,7 @@ func TestIssuesService_ListByRepo_invalidOwner(t *testing.T) { } func TestIssuesService_Get(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1", func(w http.ResponseWriter, r *http.Request) { @@ -175,7 +175,7 @@ func TestIssuesService_Get(t *testing.T) { } func TestIssuesService_Get_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.Get(context.Background(), "%", "r", 1) @@ -183,7 +183,7 @@ func TestIssuesService_Get_invalidOwner(t *testing.T) { } func TestIssuesService_Create(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &IssueRequest{ @@ -217,7 +217,7 @@ func TestIssuesService_Create(t *testing.T) { } func TestIssuesService_Create_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.Create(context.Background(), "%", "r", nil) @@ -225,7 +225,7 @@ func TestIssuesService_Create_invalidOwner(t *testing.T) { } func TestIssuesService_Edit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &IssueRequest{Title: String("t")} @@ -254,7 +254,7 @@ func TestIssuesService_Edit(t *testing.T) { } func TestIssuesService_Edit_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Issues.Edit(context.Background(), "%", "r", 1, nil) @@ -262,7 +262,7 @@ func TestIssuesService_Edit_invalidOwner(t *testing.T) { } func TestIssuesService_Lock(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) { @@ -277,7 +277,7 @@ func TestIssuesService_Lock(t *testing.T) { } func TestIssuesService_Unlock(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index cfb0ba1be3f..27f76e02c72 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -14,7 +14,7 @@ import ( ) func TestIssuesService_ListIssueTimeline(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/timeline", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/licenses_test.go b/github/licenses_test.go index 389093af178..c61cd525432 100644 --- a/github/licenses_test.go +++ b/github/licenses_test.go @@ -14,7 +14,7 @@ import ( ) func TestLicensesService_List(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/licenses", func(w http.ResponseWriter, r *http.Request) { @@ -41,7 +41,7 @@ func TestLicensesService_List(t *testing.T) { } func TestLicensesService_Get(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/licenses/mit", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestLicensesService_Get(t *testing.T) { } func TestLicensesService_Get_invalidTemplate(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Licenses.Get(context.Background(), "%") diff --git a/github/migrations_source_import_test.go b/github/migrations_source_import_test.go index 0bf92d7d1a8..dd407e68a32 100644 --- a/github/migrations_source_import_test.go +++ b/github/migrations_source_import_test.go @@ -15,7 +15,7 @@ import ( ) func TestMigrationService_StartImport(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Import{ @@ -50,7 +50,7 @@ func TestMigrationService_StartImport(t *testing.T) { } func TestMigrationService_ImportProgress(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestMigrationService_ImportProgress(t *testing.T) { } func TestMigrationService_UpdateImport(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Import{ @@ -105,7 +105,7 @@ func TestMigrationService_UpdateImport(t *testing.T) { } func TestMigrationService_CommitAuthors(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import/authors", func(w http.ResponseWriter, r *http.Request) { @@ -128,7 +128,7 @@ func TestMigrationService_CommitAuthors(t *testing.T) { } func TestMigrationService_MapCommitAuthor(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &SourceImportAuthor{Name: String("n"), Email: String("e")} @@ -157,7 +157,7 @@ func TestMigrationService_MapCommitAuthor(t *testing.T) { } func TestMigrationService_SetLFSPreference(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Import{UseLFS: String("opt_in")} @@ -187,7 +187,7 @@ func TestMigrationService_SetLFSPreference(t *testing.T) { } func TestMigrationService_LargeFiles(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import/large_files", func(w http.ResponseWriter, r *http.Request) { @@ -210,7 +210,7 @@ func TestMigrationService_LargeFiles(t *testing.T) { } func TestMigrationService_CancelImport(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/migrations_test.go b/github/migrations_test.go index d318e9ec4e2..003506e5415 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -15,7 +15,7 @@ import ( ) func TestMigrationService_StartMigration(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestMigrationService_StartMigration(t *testing.T) { } func TestMigrationService_ListMigrations(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations", func(w http.ResponseWriter, r *http.Request) { @@ -61,7 +61,7 @@ func TestMigrationService_ListMigrations(t *testing.T) { } func TestMigrationService_MigrationStatus(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1", func(w http.ResponseWriter, r *http.Request) { @@ -82,7 +82,7 @@ func TestMigrationService_MigrationStatus(t *testing.T) { } func TestMigrationService_MigrationArchiveURL(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) { @@ -108,7 +108,7 @@ func TestMigrationService_MigrationArchiveURL(t *testing.T) { } func TestMigrationService_DeleteMigration(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) { @@ -124,7 +124,7 @@ func TestMigrationService_DeleteMigration(t *testing.T) { } func TestMigrationService_UnlockRepo(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/repos/r/lock", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/misc_test.go b/github/misc_test.go index 21c471a59de..07cef26e934 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -15,7 +15,7 @@ import ( ) func TestMarkdown(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &markdownRequest{ @@ -48,7 +48,7 @@ func TestMarkdown(t *testing.T) { } func TestListEmojis(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/emojis", func(w http.ResponseWriter, r *http.Request) { @@ -68,7 +68,7 @@ func TestListEmojis(t *testing.T) { } func TestListCodesOfConduct(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/codes_of_conduct", func(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func TestListCodesOfConduct(t *testing.T) { } func TestGetCodeOfConduct(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/codes_of_conduct/k", func(w http.ResponseWriter, r *http.Request) { @@ -129,7 +129,7 @@ func TestGetCodeOfConduct(t *testing.T) { } func TestAPIMeta(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/meta", func(w http.ResponseWriter, r *http.Request) { @@ -154,7 +154,7 @@ func TestAPIMeta(t *testing.T) { } func TestOctocat(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := "input" @@ -178,7 +178,7 @@ func TestOctocat(t *testing.T) { } func TestZen(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() output := "sample text" @@ -200,7 +200,7 @@ func TestZen(t *testing.T) { } func TestListServiceHooks(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/hooks", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_hooks_test.go b/github/orgs_hooks_test.go index 96317f72924..29c3de8c5ca 100644 --- a/github/orgs_hooks_test.go +++ b/github/orgs_hooks_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListHooks(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestOrganizationsService_ListHooks(t *testing.T) { } func TestOrganizationsService_ListHooks_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.ListHooks(context.Background(), "%", nil) @@ -46,7 +46,7 @@ func TestOrganizationsService_ListHooks_invalidOrg(t *testing.T) { } func TestOrganizationsService_GetHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -66,7 +66,7 @@ func TestOrganizationsService_GetHook(t *testing.T) { } func TestOrganizationsService_GetHook_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.GetHook(context.Background(), "%", 1) @@ -74,7 +74,7 @@ func TestOrganizationsService_GetHook_invalidOrg(t *testing.T) { } func TestOrganizationsService_EditHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -103,7 +103,7 @@ func TestOrganizationsService_EditHook(t *testing.T) { } func TestOrganizationsService_EditHook_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.EditHook(context.Background(), "%", 1, nil) @@ -111,7 +111,7 @@ func TestOrganizationsService_EditHook_invalidOrg(t *testing.T) { } func TestOrganizationsService_PingHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestOrganizationsService_PingHook(t *testing.T) { } func TestOrganizationsService_DeleteHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -139,7 +139,7 @@ func TestOrganizationsService_DeleteHook(t *testing.T) { } func TestOrganizationsService_DeleteHook_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Organizations.DeleteHook(context.Background(), "%", 1) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index c6d5220fc72..4cdcee3fdca 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -16,7 +16,7 @@ import ( ) func TestOrganizationsService_ListMembers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members", func(w http.ResponseWriter, r *http.Request) { @@ -47,7 +47,7 @@ func TestOrganizationsService_ListMembers(t *testing.T) { } func TestOrganizationsService_ListMembers_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.ListMembers(context.Background(), "%", nil) @@ -55,7 +55,7 @@ func TestOrganizationsService_ListMembers_invalidOrg(t *testing.T) { } func TestOrganizationsService_ListMembers_public(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members", func(w http.ResponseWriter, r *http.Request) { @@ -76,7 +76,7 @@ func TestOrganizationsService_ListMembers_public(t *testing.T) { } func TestOrganizationsService_IsMember(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -95,7 +95,7 @@ func TestOrganizationsService_IsMember(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsMember_notMember(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -115,7 +115,7 @@ func TestOrganizationsService_IsMember_notMember(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsMember_error(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -133,7 +133,7 @@ func TestOrganizationsService_IsMember_error(t *testing.T) { } func TestOrganizationsService_IsMember_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.IsMember(context.Background(), "%", "u") @@ -141,7 +141,7 @@ func TestOrganizationsService_IsMember_invalidOrg(t *testing.T) { } func TestOrganizationsService_IsPublicMember(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -160,7 +160,7 @@ func TestOrganizationsService_IsPublicMember(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -180,7 +180,7 @@ func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsPublicMember_error(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -198,7 +198,7 @@ func TestOrganizationsService_IsPublicMember_error(t *testing.T) { } func TestOrganizationsService_IsPublicMember_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.IsPublicMember(context.Background(), "%", "u") @@ -206,7 +206,7 @@ func TestOrganizationsService_IsPublicMember_invalidOrg(t *testing.T) { } func TestOrganizationsService_RemoveMember(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -220,7 +220,7 @@ func TestOrganizationsService_RemoveMember(t *testing.T) { } func TestOrganizationsService_RemoveMember_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Organizations.RemoveMember(context.Background(), "%", "u") @@ -228,7 +228,7 @@ func TestOrganizationsService_RemoveMember_invalidOrg(t *testing.T) { } func TestOrganizationsService_ListOrgMemberships(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/memberships/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -256,7 +256,7 @@ func TestOrganizationsService_ListOrgMemberships(t *testing.T) { } func TestOrganizationsService_GetOrgMembership_AuthenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/memberships/orgs/o", func(w http.ResponseWriter, r *http.Request) { @@ -276,7 +276,7 @@ func TestOrganizationsService_GetOrgMembership_AuthenticatedUser(t *testing.T) { } func TestOrganizationsService_GetOrgMembership_SpecifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -296,7 +296,7 @@ func TestOrganizationsService_GetOrgMembership_SpecifiedUser(t *testing.T) { } func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Membership{State: String("active")} @@ -325,7 +325,7 @@ func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) } func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Membership{State: String("active")} @@ -354,7 +354,7 @@ func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) { } func TestOrganizationsService_RemoveOrgMembership(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -369,7 +369,7 @@ func TestOrganizationsService_RemoveOrgMembership(t *testing.T) { } func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/invitations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_outside_collaborators_test.go b/github/orgs_outside_collaborators_test.go index 962103fc270..f5dcd46647a 100644 --- a/github/orgs_outside_collaborators_test.go +++ b/github/orgs_outside_collaborators_test.go @@ -14,7 +14,7 @@ import ( ) func TestOrganizationsService_ListOutsideCollaborators(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/outside_collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestOrganizationsService_ListOutsideCollaborators(t *testing.T) { } func TestOrganizationsService_ListOutsideCollaborators_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.ListOutsideCollaborators(context.Background(), "%", nil) diff --git a/github/orgs_projects_test.go b/github/orgs_projects_test.go index 4b8dfb9e2f3..92831262791 100644 --- a/github/orgs_projects_test.go +++ b/github/orgs_projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListProjects(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/projects", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestOrganizationsService_ListProjects(t *testing.T) { } func TestOrganizationsService_CreateProject(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body."} diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 67c47c22100..b7a3fd3def2 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -16,7 +16,7 @@ import ( ) func TestOrganizationsService_ListTeams(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/teams", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestOrganizationsService_ListTeams(t *testing.T) { } func TestOrganizationsService_ListTeams_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.ListTeams(context.Background(), "%", nil) @@ -46,7 +46,7 @@ func TestOrganizationsService_ListTeams_invalidOrg(t *testing.T) { } func TestOrganizationsService_GetTeam(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { @@ -66,7 +66,7 @@ func TestOrganizationsService_GetTeam(t *testing.T) { } func TestOrganizationsService_CreateTeam(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Team{Name: String("n"), Privacy: String("closed")} @@ -95,7 +95,7 @@ func TestOrganizationsService_CreateTeam(t *testing.T) { } func TestOrganizationsService_CreateTeam_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.CreateTeam(context.Background(), "%", nil) @@ -103,7 +103,7 @@ func TestOrganizationsService_CreateTeam_invalidOrg(t *testing.T) { } func TestOrganizationsService_EditTeam(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Team{Name: String("n"), Privacy: String("closed")} @@ -132,7 +132,7 @@ func TestOrganizationsService_EditTeam(t *testing.T) { } func TestOrganizationsService_DeleteTeam(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { @@ -146,7 +146,7 @@ func TestOrganizationsService_DeleteTeam(t *testing.T) { } func TestOrganizationsService_ListTeamMembers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members", func(w http.ResponseWriter, r *http.Request) { @@ -168,7 +168,7 @@ func TestOrganizationsService_ListTeamMembers(t *testing.T) { } func TestOrganizationsService_IsTeamMember_true(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -186,7 +186,7 @@ func TestOrganizationsService_IsTeamMember_true(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsTeamMember_false(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -206,7 +206,7 @@ func TestOrganizationsService_IsTeamMember_false(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsTeamMember_error(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -224,7 +224,7 @@ func TestOrganizationsService_IsTeamMember_error(t *testing.T) { } func TestOrganizationsService_IsTeamMember_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.IsTeamMember(context.Background(), 1, "%") @@ -232,7 +232,7 @@ func TestOrganizationsService_IsTeamMember_invalidUser(t *testing.T) { } func TestOrganizationsService_PublicizeMembership(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -247,7 +247,7 @@ func TestOrganizationsService_PublicizeMembership(t *testing.T) { } func TestOrganizationsService_PublicizeMembership_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Organizations.PublicizeMembership(context.Background(), "%", "u") @@ -255,7 +255,7 @@ func TestOrganizationsService_PublicizeMembership_invalidOrg(t *testing.T) { } func TestOrganizationsService_ConcealMembership(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -270,7 +270,7 @@ func TestOrganizationsService_ConcealMembership(t *testing.T) { } func TestOrganizationsService_ConcealMembership_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Organizations.ConcealMembership(context.Background(), "%", "u") @@ -278,7 +278,7 @@ func TestOrganizationsService_ConcealMembership_invalidOrg(t *testing.T) { } func TestOrganizationsService_ListTeamRepos(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos", func(w http.ResponseWriter, r *http.Request) { @@ -301,7 +301,7 @@ func TestOrganizationsService_ListTeamRepos(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_true(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -322,7 +322,7 @@ func TestOrganizationsService_IsTeamRepo_true(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_false(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -343,7 +343,7 @@ func TestOrganizationsService_IsTeamRepo_false(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_error(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -364,7 +364,7 @@ func TestOrganizationsService_IsTeamRepo_error(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.IsTeamRepo(context.Background(), 1, "%", "r") @@ -372,7 +372,7 @@ func TestOrganizationsService_IsTeamRepo_invalidOwner(t *testing.T) { } func TestOrganizationsService_AddTeamRepo(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() opt := &OrganizationAddTeamRepoOptions{Permission: "admin"} @@ -396,7 +396,7 @@ func TestOrganizationsService_AddTeamRepo(t *testing.T) { } func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -411,7 +411,7 @@ func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) { } func TestOrganizationsService_AddTeamRepo_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Organizations.AddTeamRepo(context.Background(), 1, "%", "r", nil) @@ -419,7 +419,7 @@ func TestOrganizationsService_AddTeamRepo_invalidOwner(t *testing.T) { } func TestOrganizationsService_RemoveTeamRepo(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -434,7 +434,7 @@ func TestOrganizationsService_RemoveTeamRepo(t *testing.T) { } func TestOrganizationsService_RemoveTeamRepo_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Organizations.RemoveTeamRepo(context.Background(), 1, "%", "r") @@ -442,7 +442,7 @@ func TestOrganizationsService_RemoveTeamRepo_invalidOwner(t *testing.T) { } func TestOrganizationsService_GetTeamMembership(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -462,7 +462,7 @@ func TestOrganizationsService_GetTeamMembership(t *testing.T) { } func TestOrganizationsService_AddTeamMembership(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() opt := &OrganizationAddTeamMembershipOptions{Role: "maintainer"} @@ -491,7 +491,7 @@ func TestOrganizationsService_AddTeamMembership(t *testing.T) { } func TestOrganizationsService_RemoveTeamMembership(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -506,7 +506,7 @@ func TestOrganizationsService_RemoveTeamMembership(t *testing.T) { } func TestOrganizationsService_ListUserTeams(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/teams", func(w http.ResponseWriter, r *http.Request) { @@ -528,7 +528,7 @@ func TestOrganizationsService_ListUserTeams(t *testing.T) { } func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/invitations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_test.go b/github/orgs_test.go index 2b48df7b790..87f6ba966e2 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListAll(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() since := 1342004 @@ -38,7 +38,7 @@ func TestOrganizationsService_ListAll(t *testing.T) { } func TestOrganizationsService_List_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestOrganizationsService_List_authenticatedUser(t *testing.T) { } func TestOrganizationsService_List_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -80,7 +80,7 @@ func TestOrganizationsService_List_specifiedUser(t *testing.T) { } func TestOrganizationsService_List_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.List(context.Background(), "%", nil) @@ -88,7 +88,7 @@ func TestOrganizationsService_List_invalidUser(t *testing.T) { } func TestOrganizationsService_Get(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) { @@ -108,7 +108,7 @@ func TestOrganizationsService_Get(t *testing.T) { } func TestOrganizationsService_Get_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.Get(context.Background(), "%") @@ -116,7 +116,7 @@ func TestOrganizationsService_Get_invalidOrg(t *testing.T) { } func TestOrganizationsService_GetByID(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/organizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -136,7 +136,7 @@ func TestOrganizationsService_GetByID(t *testing.T) { } func TestOrganizationsService_Edit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Organization{Login: String("l")} @@ -165,7 +165,7 @@ func TestOrganizationsService_Edit(t *testing.T) { } func TestOrganizationsService_Edit_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Organizations.Edit(context.Background(), "%", nil) diff --git a/github/orgs_users_blocking_test.go b/github/orgs_users_blocking_test.go index a85aead488c..8b6bdcd5c0f 100644 --- a/github/orgs_users_blocking_test.go +++ b/github/orgs_users_blocking_test.go @@ -14,7 +14,7 @@ import ( ) func TestOrganizationsService_ListBlockedUsers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestOrganizationsService_ListBlockedUsers(t *testing.T) { } func TestOrganizationsService_IsBlocked(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestOrganizationsService_IsBlocked(t *testing.T) { } func TestOrganizationsService_BlockUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func TestOrganizationsService_BlockUser(t *testing.T) { } func TestOrganizationsService_UnblockUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/projects_test.go b/github/projects_test.go index cd61ea662e0..2f15ebe706a 100644 --- a/github/projects_test.go +++ b/github/projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestProjectsService_UpdateProject(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body.", State: "open"} @@ -45,7 +45,7 @@ func TestProjectsService_UpdateProject(t *testing.T) { } func TestProjectsService_GetProject(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { @@ -66,7 +66,7 @@ func TestProjectsService_GetProject(t *testing.T) { } func TestProjectsService_DeleteProject(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { @@ -81,7 +81,7 @@ func TestProjectsService_DeleteProject(t *testing.T) { } func TestProjectsService_ListProjectColumns(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/projects/1/columns", func(w http.ResponseWriter, r *http.Request) { @@ -104,7 +104,7 @@ func TestProjectsService_ListProjectColumns(t *testing.T) { } func TestProjectsService_GetProjectColumn(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestProjectsService_GetProjectColumn(t *testing.T) { } func TestProjectsService_CreateProjectColumn(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectColumnOptions{Name: "Column Name"} @@ -155,7 +155,7 @@ func TestProjectsService_CreateProjectColumn(t *testing.T) { } func TestProjectsService_UpdateProjectColumn(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectColumnOptions{Name: "Column Name"} @@ -185,7 +185,7 @@ func TestProjectsService_UpdateProjectColumn(t *testing.T) { } func TestProjectsService_DeleteProjectColumn(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { @@ -200,7 +200,7 @@ func TestProjectsService_DeleteProjectColumn(t *testing.T) { } func TestProjectsService_MoveProjectColumn(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectColumnMoveOptions{Position: "after:12345"} @@ -223,7 +223,7 @@ func TestProjectsService_MoveProjectColumn(t *testing.T) { } func TestProjectsService_ListProjectCards(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1/cards", func(w http.ResponseWriter, r *http.Request) { @@ -246,7 +246,7 @@ func TestProjectsService_ListProjectCards(t *testing.T) { } func TestProjectsService_GetProjectCard(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { @@ -267,7 +267,7 @@ func TestProjectsService_GetProjectCard(t *testing.T) { } func TestProjectsService_CreateProjectCard(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectCardOptions{ @@ -300,7 +300,7 @@ func TestProjectsService_CreateProjectCard(t *testing.T) { } func TestProjectsService_UpdateProjectCard(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectCardOptions{ @@ -333,7 +333,7 @@ func TestProjectsService_UpdateProjectCard(t *testing.T) { } func TestProjectsService_DeleteProjectCard(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { @@ -348,7 +348,7 @@ func TestProjectsService_DeleteProjectCard(t *testing.T) { } func TestProjectsService_MoveProjectCard(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectCardMoveOptions{Position: "after:12345"} diff --git a/github/pulls_comments_test.go b/github/pulls_comments_test.go index 0e7fb96e757..fbc5d669b47 100644 --- a/github/pulls_comments_test.go +++ b/github/pulls_comments_test.go @@ -16,7 +16,7 @@ import ( ) func TestPullRequestsService_ListComments_allPulls(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) { } func TestPullRequestsService_ListComments_specificPull(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestPullRequestsService_ListComments_specificPull(t *testing.T) { } func TestPullRequestsService_ListComments_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.ListComments(context.Background(), "%", "r", 1, nil) @@ -78,7 +78,7 @@ func TestPullRequestsService_ListComments_invalidOwner(t *testing.T) { } func TestPullRequestsService_GetComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -99,7 +99,7 @@ func TestPullRequestsService_GetComment(t *testing.T) { } func TestPullRequestsService_GetComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.GetComment(context.Background(), "%", "r", 1) @@ -107,7 +107,7 @@ func TestPullRequestsService_GetComment_invalidOwner(t *testing.T) { } func TestPullRequestsService_CreateComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &PullRequestComment{Body: String("b")} @@ -136,7 +136,7 @@ func TestPullRequestsService_CreateComment(t *testing.T) { } func TestPullRequestsService_CreateComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.CreateComment(context.Background(), "%", "r", 1, nil) @@ -144,7 +144,7 @@ func TestPullRequestsService_CreateComment_invalidOwner(t *testing.T) { } func TestPullRequestsService_EditComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &PullRequestComment{Body: String("b")} @@ -173,7 +173,7 @@ func TestPullRequestsService_EditComment(t *testing.T) { } func TestPullRequestsService_EditComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.EditComment(context.Background(), "%", "r", 1, nil) @@ -181,7 +181,7 @@ func TestPullRequestsService_EditComment_invalidOwner(t *testing.T) { } func TestPullRequestsService_DeleteComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -195,7 +195,7 @@ func TestPullRequestsService_DeleteComment(t *testing.T) { } func TestPullRequestsService_DeleteComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.PullRequests.DeleteComment(context.Background(), "%", "r", 1) diff --git a/github/pulls_reviewers_test.go b/github/pulls_reviewers_test.go index 3fda247e448..f366d0e2a67 100644 --- a/github/pulls_reviewers_test.go +++ b/github/pulls_reviewers_test.go @@ -14,7 +14,7 @@ import ( ) func TestRequestReviewers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestRequestReviewers(t *testing.T) { } func TestRemoveReviewers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -52,7 +52,7 @@ func TestRemoveReviewers(t *testing.T) { } func TestListReviewers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -86,7 +86,7 @@ func TestListReviewers(t *testing.T) { } func TestListReviewers_withOptions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index e92a2869478..b0590e6d1e2 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -15,7 +15,7 @@ import ( ) func TestPullRequestsService_ListReviews(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestPullRequestsService_ListReviews(t *testing.T) { } func TestPullRequestsService_ListReviews_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.ListReviews(context.Background(), "%", "r", 1, nil) @@ -50,7 +50,7 @@ func TestPullRequestsService_ListReviews_invalidOwner(t *testing.T) { } func TestPullRequestsService_GetReview(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestPullRequestsService_GetReview(t *testing.T) { } func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.GetReview(context.Background(), "%", "r", 1, 1) @@ -78,7 +78,7 @@ func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) { } func TestPullRequestsService_DeletePendingReview(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func TestPullRequestsService_DeletePendingReview(t *testing.T) { } func TestPullRequestsService_DeletePendingReview_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.DeletePendingReview(context.Background(), "%", "r", 1, 1) @@ -106,7 +106,7 @@ func TestPullRequestsService_DeletePendingReview_invalidOwner(t *testing.T) { } func TestPullRequestsService_ListReviewComments(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -129,7 +129,7 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) { } func TestPullRequestsService_ListReviewComments_withOptions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -147,7 +147,7 @@ func TestPullRequestsService_ListReviewComments_withOptions(t *testing.T) { } func TestPullRequestsService_ListReviewComments_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.ListReviewComments(context.Background(), "%", "r", 1, 1, nil) @@ -155,7 +155,7 @@ func TestPullRequestsService_ListReviewComments_invalidOwner(t *testing.T) { } func TestPullRequestsService_CreateReview(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &PullRequestReviewRequest{ @@ -188,7 +188,7 @@ func TestPullRequestsService_CreateReview(t *testing.T) { } func TestPullRequestsService_CreateReview_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.CreateReview(context.Background(), "%", "r", 1, &PullRequestReviewRequest{}) @@ -196,7 +196,7 @@ func TestPullRequestsService_CreateReview_invalidOwner(t *testing.T) { } func TestPullRequestsService_SubmitReview(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &PullRequestReviewRequest{ @@ -228,7 +228,7 @@ func TestPullRequestsService_SubmitReview(t *testing.T) { } func TestPullRequestsService_SubmitReview_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.SubmitReview(context.Background(), "%", "r", 1, 1, &PullRequestReviewRequest{}) @@ -236,7 +236,7 @@ func TestPullRequestsService_SubmitReview_invalidOwner(t *testing.T) { } func TestPullRequestsService_DismissReview(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &PullRequestReviewDismissalRequest{Message: String("m")} @@ -265,7 +265,7 @@ func TestPullRequestsService_DismissReview(t *testing.T) { } func TestPullRequestsService_DismissReview_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.DismissReview(context.Background(), "%", "r", 1, 1, &PullRequestReviewDismissalRequest{}) diff --git a/github/pulls_test.go b/github/pulls_test.go index 101a8db572c..9ab8000c427 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -17,7 +17,7 @@ import ( ) func TestPullRequestsService_List(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) { @@ -46,7 +46,7 @@ func TestPullRequestsService_List(t *testing.T) { } func TestPullRequestsService_List_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.List(context.Background(), "%", "r", nil) @@ -54,7 +54,7 @@ func TestPullRequestsService_List_invalidOwner(t *testing.T) { } func TestPullRequestsService_Get(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func TestPullRequestsService_Get(t *testing.T) { } func TestPullRequestsService_GetRawDiff(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() const rawStr = "@@diff content" @@ -95,7 +95,7 @@ func TestPullRequestsService_GetRawDiff(t *testing.T) { } func TestPullRequestsService_GetRawPatch(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() const rawStr = "@@patch content" @@ -116,7 +116,7 @@ func TestPullRequestsService_GetRawPatch(t *testing.T) { } func TestPullRequestsService_GetRawInvalid(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{100}) @@ -129,7 +129,7 @@ func TestPullRequestsService_GetRawInvalid(t *testing.T) { } func TestPullRequestsService_Get_headAndBase(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -159,7 +159,7 @@ func TestPullRequestsService_Get_headAndBase(t *testing.T) { } func TestPullRequestsService_Get_urlFields(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -198,7 +198,7 @@ func TestPullRequestsService_Get_urlFields(t *testing.T) { } func TestPullRequestsService_Get_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.Get(context.Background(), "%", "r", 1) @@ -206,7 +206,7 @@ func TestPullRequestsService_Get_invalidOwner(t *testing.T) { } func TestPullRequestsService_Create(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &NewPullRequest{Title: String("t")} @@ -235,7 +235,7 @@ func TestPullRequestsService_Create(t *testing.T) { } func TestPullRequestsService_Create_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.Create(context.Background(), "%", "r", nil) @@ -243,7 +243,7 @@ func TestPullRequestsService_Create_invalidOwner(t *testing.T) { } func TestPullRequestsService_Edit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() tests := []struct { @@ -296,7 +296,7 @@ func TestPullRequestsService_Edit(t *testing.T) { } func TestPullRequestsService_Edit_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.PullRequests.Edit(context.Background(), "%", "r", 1, &PullRequest{}) @@ -304,7 +304,7 @@ func TestPullRequestsService_Edit_invalidOwner(t *testing.T) { } func TestPullRequestsService_ListCommits(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -362,7 +362,7 @@ func TestPullRequestsService_ListCommits(t *testing.T) { } func TestPullRequestsService_ListFiles(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/files", func(w http.ResponseWriter, r *http.Request) { @@ -424,7 +424,7 @@ func TestPullRequestsService_ListFiles(t *testing.T) { } func TestPullRequestsService_IsMerged(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) { @@ -444,7 +444,7 @@ func TestPullRequestsService_IsMerged(t *testing.T) { } func TestPullRequestsService_Merge(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) { @@ -475,7 +475,7 @@ func TestPullRequestsService_Merge(t *testing.T) { // Test that different merge options produce expected PUT requests. See issue https://github.com/google/go-github/issues/500. func TestPullRequestsService_Merge_options(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() tests := []struct { diff --git a/github/reactions_test.go b/github/reactions_test.go index 83b127e68e2..f191fd8bb35 100644 --- a/github/reactions_test.go +++ b/github/reactions_test.go @@ -13,7 +13,7 @@ import ( ) func TestReactionsService_ListCommentReactions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -34,7 +34,7 @@ func TestReactionsService_ListCommentReactions(t *testing.T) { } func TestReactionsService_CreateCommentReaction(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -56,7 +56,7 @@ func TestReactionsService_CreateCommentReaction(t *testing.T) { } func TestReactionsService_ListIssueReactions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -77,7 +77,7 @@ func TestReactionsService_ListIssueReactions(t *testing.T) { } func TestReactionsService_CreateIssueReaction(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -99,7 +99,7 @@ func TestReactionsService_CreateIssueReaction(t *testing.T) { } func TestReactionsService_ListIssueCommentReactions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -120,7 +120,7 @@ func TestReactionsService_ListIssueCommentReactions(t *testing.T) { } func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -142,7 +142,7 @@ func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { } func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -163,7 +163,7 @@ func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { } func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -185,7 +185,7 @@ func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { } func TestReactionsService_DeleteReaction(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/reactions/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index 7e234e1899c..096b24ff5af 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListCollaborators(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) { } func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -64,7 +64,7 @@ func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) { } func TestRepositoriesService_ListCollaborators_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListCollaborators(context.Background(), "%", "%", nil) @@ -72,7 +72,7 @@ func TestRepositoriesService_ListCollaborators_invalidOwner(t *testing.T) { } func TestRepositoriesService_IsCollaborator_True(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -91,7 +91,7 @@ func TestRepositoriesService_IsCollaborator_True(t *testing.T) { } func TestRepositoriesService_IsCollaborator_False(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -110,7 +110,7 @@ func TestRepositoriesService_IsCollaborator_False(t *testing.T) { } func TestRepositoriesService_IsCollaborator_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.IsCollaborator(context.Background(), "%", "%", "%") @@ -118,7 +118,7 @@ func TestRepositoriesService_IsCollaborator_invalidUser(t *testing.T) { } func TestRepositoryService_GetPermissionLevel(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u/permission", func(w http.ResponseWriter, r *http.Request) { @@ -144,7 +144,7 @@ func TestRepositoryService_GetPermissionLevel(t *testing.T) { } func TestRepositoriesService_AddCollaborator(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() opt := &RepositoryAddCollaboratorOptions{Permission: "admin"} @@ -169,7 +169,7 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) { } func TestRepositoriesService_AddCollaborator_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Repositories.AddCollaborator(context.Background(), "%", "%", "%", nil) @@ -177,7 +177,7 @@ func TestRepositoriesService_AddCollaborator_invalidUser(t *testing.T) { } func TestRepositoriesService_RemoveCollaborator(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -192,7 +192,7 @@ func TestRepositoriesService_RemoveCollaborator(t *testing.T) { } func TestRepositoriesService_RemoveCollaborator_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Repositories.RemoveCollaborator(context.Background(), "%", "%", "%") diff --git a/github/repos_comments_test.go b/github/repos_comments_test.go index 44644cd3ff8..5f6571c1cab 100644 --- a/github/repos_comments_test.go +++ b/github/repos_comments_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListComments(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestRepositoriesService_ListComments(t *testing.T) { } func TestRepositoriesService_ListComments_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListComments(context.Background(), "%", "%", nil) @@ -46,7 +46,7 @@ func TestRepositoriesService_ListComments_invalidOwner(t *testing.T) { } func TestRepositoriesService_ListCommitComments(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/s/comments", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestRepositoriesService_ListCommitComments(t *testing.T) { } func TestRepositoriesService_ListCommitComments_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListCommitComments(context.Background(), "%", "%", "%", nil) @@ -77,7 +77,7 @@ func TestRepositoriesService_ListCommitComments_invalidOwner(t *testing.T) { } func TestRepositoriesService_CreateComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &RepositoryComment{Body: String("b")} @@ -106,7 +106,7 @@ func TestRepositoriesService_CreateComment(t *testing.T) { } func TestRepositoriesService_CreateComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateComment(context.Background(), "%", "%", "%", nil) @@ -114,7 +114,7 @@ func TestRepositoriesService_CreateComment_invalidOwner(t *testing.T) { } func TestRepositoriesService_GetComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -135,7 +135,7 @@ func TestRepositoriesService_GetComment(t *testing.T) { } func TestRepositoriesService_GetComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.GetComment(context.Background(), "%", "%", 1) @@ -143,7 +143,7 @@ func TestRepositoriesService_GetComment_invalidOwner(t *testing.T) { } func TestRepositoriesService_UpdateComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &RepositoryComment{Body: String("b")} @@ -172,7 +172,7 @@ func TestRepositoriesService_UpdateComment(t *testing.T) { } func TestRepositoriesService_UpdateComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.UpdateComment(context.Background(), "%", "%", 1, nil) @@ -180,7 +180,7 @@ func TestRepositoriesService_UpdateComment_invalidOwner(t *testing.T) { } func TestRepositoriesService_DeleteComment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -194,7 +194,7 @@ func TestRepositoriesService_DeleteComment(t *testing.T) { } func TestRepositoriesService_DeleteComment_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Repositories.DeleteComment(context.Background(), "%", "%", 1) diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 22622979903..6f4fe94a269 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListCommits(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() // given @@ -52,7 +52,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) { } func TestRepositoriesService_GetCommit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) { @@ -127,7 +127,7 @@ func TestRepositoriesService_GetCommit(t *testing.T) { } func TestRepositoriesService_GetCommitSHA1(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() const sha1 = "01234abcde" @@ -168,7 +168,7 @@ func TestRepositoriesService_GetCommitSHA1(t *testing.T) { } func TestRepositoriesService_CompareCommits(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/compare/b...h", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_community_health_test.go b/github/repos_community_health_test.go index 5bc65962263..e3cb9d03d9f 100644 --- a/github/repos_community_health_test.go +++ b/github/repos_community_health_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/community/profile", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index 2d5f7ee5df2..cf6323b7f58 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -68,7 +68,7 @@ func TestRepositoryContent_GetContent(t *testing.T) { } func TestRepositoriesService_GetReadme(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/readme", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -91,14 +91,14 @@ func TestRepositoriesService_GetReadme(t *testing.T) { } func TestRepositoriesService_DownloadContents_Success(t *testing.T) { - client, teardown := setup() + serverBaseURL, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[{ "type": "file", "name": "f", - "download_url": "`+server.URL+baseURLPath+`/download/f" + "download_url": "`+serverBaseURL+baseURLPath+`/download/f" }]`) }) mux.HandleFunc("/download/f", func(w http.ResponseWriter, r *http.Request) { @@ -123,7 +123,7 @@ func TestRepositoriesService_DownloadContents_Success(t *testing.T) { } func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -140,7 +140,7 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { } func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -154,7 +154,7 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { } func TestRepositoriesService_GetContents_File(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -177,7 +177,7 @@ func TestRepositoriesService_GetContents_File(t *testing.T) { } func TestRepositoriesService_GetContents_FilenameNeedsEscape(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p#?%/δΈ­.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -190,7 +190,7 @@ func TestRepositoriesService_GetContents_FilenameNeedsEscape(t *testing.T) { } func TestRepositoriesService_GetContents_DirectoryWithSpaces(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/some directory/file.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -203,7 +203,7 @@ func TestRepositoriesService_GetContents_DirectoryWithSpaces(t *testing.T) { } func TestRepositoriesService_GetContents_DirectoryWithPlusChars(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/some directory+name/file.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -216,7 +216,7 @@ func TestRepositoriesService_GetContents_DirectoryWithPlusChars(t *testing.T) { } func TestRepositoriesService_GetContents_Directory(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -244,7 +244,7 @@ func TestRepositoriesService_GetContents_Directory(t *testing.T) { } func TestRepositoriesService_CreateFile(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -282,7 +282,7 @@ func TestRepositoriesService_CreateFile(t *testing.T) { } func TestRepositoriesService_UpdateFile(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -322,7 +322,7 @@ func TestRepositoriesService_UpdateFile(t *testing.T) { } func TestRepositoriesService_DeleteFile(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") @@ -358,7 +358,7 @@ func TestRepositoriesService_DeleteFile(t *testing.T) { } func TestRepositoriesService_GetArchiveLink(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/tarball", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") diff --git a/github/repos_deployments_test.go b/github/repos_deployments_test.go index c23316b79dd..f39c98dff73 100644 --- a/github/repos_deployments_test.go +++ b/github/repos_deployments_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListDeployments(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListDeployments(t *testing.T) { } func TestRepositoriesService_GetDeployment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/3", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestRepositoriesService_GetDeployment(t *testing.T) { } func TestRepositoriesService_CreateDeployment(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &DeploymentRequest{Ref: String("1111"), Task: String("deploy"), TransientEnvironment: Bool(true)} @@ -88,7 +88,7 @@ func TestRepositoriesService_CreateDeployment(t *testing.T) { } func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/1/statuses", func(w http.ResponseWriter, r *http.Request) { @@ -110,7 +110,7 @@ func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) { } func TestRepositoriesService_GetDeploymentStatus(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/3/statuses/4", func(w http.ResponseWriter, r *http.Request) { @@ -131,7 +131,7 @@ func TestRepositoriesService_GetDeploymentStatus(t *testing.T) { } func TestRepositoriesService_CreateDeploymentStatus(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &DeploymentStatusRequest{State: String("inactive"), Description: String("deploy"), AutoInactive: Bool(false)} diff --git a/github/repos_forks_test.go b/github/repos_forks_test.go index 09172b7fa16..3a0159375ee 100644 --- a/github/repos_forks_test.go +++ b/github/repos_forks_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_ListForks(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { @@ -43,7 +43,7 @@ func TestRepositoriesService_ListForks(t *testing.T) { } func TestRepositoriesService_ListForks_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListForks(context.Background(), "%", "r", nil) @@ -51,7 +51,7 @@ func TestRepositoriesService_ListForks_invalidOwner(t *testing.T) { } func TestRepositoriesService_CreateFork(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestRepositoriesService_CreateFork(t *testing.T) { } func TestRepositoriesService_CreateFork_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateFork(context.Background(), "%", "r", nil) diff --git a/github/repos_hooks_test.go b/github/repos_hooks_test.go index fdd6544d7e2..6ccfca35bda 100644 --- a/github/repos_hooks_test.go +++ b/github/repos_hooks_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_CreateHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -44,7 +44,7 @@ func TestRepositoriesService_CreateHook(t *testing.T) { } func TestRepositoriesService_CreateHook_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateHook(context.Background(), "%", "%", nil) @@ -52,7 +52,7 @@ func TestRepositoriesService_CreateHook_invalidOwner(t *testing.T) { } func TestRepositoriesService_ListHooks(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks", func(w http.ResponseWriter, r *http.Request) { @@ -75,7 +75,7 @@ func TestRepositoriesService_ListHooks(t *testing.T) { } func TestRepositoriesService_ListHooks_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListHooks(context.Background(), "%", "%", nil) @@ -83,7 +83,7 @@ func TestRepositoriesService_ListHooks_invalidOwner(t *testing.T) { } func TestRepositoriesService_GetHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -103,7 +103,7 @@ func TestRepositoriesService_GetHook(t *testing.T) { } func TestRepositoriesService_GetHook_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.GetHook(context.Background(), "%", "%", 1) @@ -111,7 +111,7 @@ func TestRepositoriesService_GetHook_invalidOwner(t *testing.T) { } func TestRepositoriesService_EditHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -140,7 +140,7 @@ func TestRepositoriesService_EditHook(t *testing.T) { } func TestRepositoriesService_EditHook_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.EditHook(context.Background(), "%", "%", 1, nil) @@ -148,7 +148,7 @@ func TestRepositoriesService_EditHook_invalidOwner(t *testing.T) { } func TestRepositoriesService_DeleteHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -162,7 +162,7 @@ func TestRepositoriesService_DeleteHook(t *testing.T) { } func TestRepositoriesService_DeleteHook_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Repositories.DeleteHook(context.Background(), "%", "%", 1) @@ -170,7 +170,7 @@ func TestRepositoriesService_DeleteHook_invalidOwner(t *testing.T) { } func TestRepositoriesService_PingHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) { @@ -184,7 +184,7 @@ func TestRepositoriesService_PingHook(t *testing.T) { } func TestRepositoriesService_TestHook(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1/tests", func(w http.ResponseWriter, r *http.Request) { @@ -198,7 +198,7 @@ func TestRepositoriesService_TestHook(t *testing.T) { } func TestRepositoriesService_TestHook_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Repositories.TestHook(context.Background(), "%", "%", 1) diff --git a/github/repos_invitations_test.go b/github/repos_invitations_test.go index 9dbadd80cdd..0d48c64e5ee 100644 --- a/github/repos_invitations_test.go +++ b/github/repos_invitations_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_ListInvitations(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListInvitations(t *testing.T) { } func TestRepositoriesService_DeleteInvitation(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) { @@ -53,7 +53,7 @@ func TestRepositoriesService_DeleteInvitation(t *testing.T) { } func TestRepositoriesService_UpdateInvitation(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_keys_test.go b/github/repos_keys_test.go index e314e748c37..090745f20be 100644 --- a/github/repos_keys_test.go +++ b/github/repos_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListKeys(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListKeys(t *testing.T) { } func TestRepositoriesService_ListKeys_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListKeys(context.Background(), "%", "%", nil) @@ -45,7 +45,7 @@ func TestRepositoriesService_ListKeys_invalidOwner(t *testing.T) { } func TestRepositoriesService_GetKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func TestRepositoriesService_GetKey(t *testing.T) { } func TestRepositoriesService_GetKey_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.GetKey(context.Background(), "%", "%", 1) @@ -73,7 +73,7 @@ func TestRepositoriesService_GetKey_invalidOwner(t *testing.T) { } func TestRepositoriesService_CreateKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -102,7 +102,7 @@ func TestRepositoriesService_CreateKey(t *testing.T) { } func TestRepositoriesService_CreateKey_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateKey(context.Background(), "%", "%", nil) @@ -110,7 +110,7 @@ func TestRepositoriesService_CreateKey_invalidOwner(t *testing.T) { } func TestRepositoriesService_EditKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -139,7 +139,7 @@ func TestRepositoriesService_EditKey(t *testing.T) { } func TestRepositoriesService_EditKey_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.EditKey(context.Background(), "%", "%", 1, nil) @@ -147,7 +147,7 @@ func TestRepositoriesService_EditKey_invalidOwner(t *testing.T) { } func TestRepositoriesService_DeleteKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -161,7 +161,7 @@ func TestRepositoriesService_DeleteKey(t *testing.T) { } func TestRepositoriesService_DeleteKey_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Repositories.DeleteKey(context.Background(), "%", "%", 1) diff --git a/github/repos_merging_test.go b/github/repos_merging_test.go index 4f19f77aab9..be4f9ed021a 100644 --- a/github/repos_merging_test.go +++ b/github/repos_merging_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_Merge(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &RepositoryMergeRequest{ diff --git a/github/repos_pages_test.go b/github/repos_pages_test.go index d08655740b6..d41d54e5e98 100644 --- a/github/repos_pages_test.go +++ b/github/repos_pages_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_GetPagesInfo(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { @@ -35,7 +35,7 @@ func TestRepositoriesService_GetPagesInfo(t *testing.T) { } func TestRepositoriesService_ListPagesBuilds(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { @@ -55,7 +55,7 @@ func TestRepositoriesService_ListPagesBuilds(t *testing.T) { } func TestRepositoriesService_ListPagesBuilds_withOptions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestRepositoriesService_ListPagesBuilds_withOptions(t *testing.T) { } func TestRepositoriesService_GetLatestPagesBuild(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds/latest", func(w http.ResponseWriter, r *http.Request) { @@ -93,7 +93,7 @@ func TestRepositoriesService_GetLatestPagesBuild(t *testing.T) { } func TestRepositoriesService_GetPageBuild(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds/1", func(w http.ResponseWriter, r *http.Request) { @@ -113,7 +113,7 @@ func TestRepositoriesService_GetPageBuild(t *testing.T) { } func TestRepositoriesService_RequestPageBuild(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_projects_test.go b/github/repos_projects_test.go index 441770a56e7..663ea8fe811 100644 --- a/github/repos_projects_test.go +++ b/github/repos_projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListProjects(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/projects", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestRepositoriesService_ListProjects(t *testing.T) { } func TestRepositoriesService_CreateProject(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body."} diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index bc6436ca496..4ca11b1fdd7 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -19,7 +19,7 @@ import ( ) func TestRepositoriesService_ListReleases(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestRepositoriesService_ListReleases(t *testing.T) { } func TestRepositoriesService_GetRelease(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { @@ -60,7 +60,7 @@ func TestRepositoriesService_GetRelease(t *testing.T) { } func TestRepositoriesService_GetLatestRelease(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/latest", func(w http.ResponseWriter, r *http.Request) { @@ -80,7 +80,7 @@ func TestRepositoriesService_GetLatestRelease(t *testing.T) { } func TestRepositoriesService_GetReleaseByTag(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/tags/foo", func(w http.ResponseWriter, r *http.Request) { @@ -100,7 +100,7 @@ func TestRepositoriesService_GetReleaseByTag(t *testing.T) { } func TestRepositoriesService_CreateRelease(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &RepositoryRelease{Name: String("v1.0")} @@ -128,7 +128,7 @@ func TestRepositoriesService_CreateRelease(t *testing.T) { } func TestRepositoriesService_EditRelease(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &RepositoryRelease{Name: String("n")} @@ -155,7 +155,7 @@ func TestRepositoriesService_EditRelease(t *testing.T) { } func TestRepositoriesService_DeleteRelease(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { @@ -169,7 +169,7 @@ func TestRepositoriesService_DeleteRelease(t *testing.T) { } func TestRepositoriesService_ListReleaseAssets(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1/assets", func(w http.ResponseWriter, r *http.Request) { @@ -190,7 +190,7 @@ func TestRepositoriesService_ListReleaseAssets(t *testing.T) { } func TestRepositoriesService_GetReleaseAsset(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -209,7 +209,7 @@ func TestRepositoriesService_GetReleaseAsset(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_Stream(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -235,7 +235,7 @@ func TestRepositoriesService_DownloadReleaseAsset_Stream(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_Redirect(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -255,7 +255,7 @@ func TestRepositoriesService_DownloadReleaseAsset_Redirect(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_APIError(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -281,7 +281,7 @@ func TestRepositoriesService_DownloadReleaseAsset_APIError(t *testing.T) { } func TestRepositoriesService_EditReleaseAsset(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ReleaseAsset{Name: String("n")} @@ -308,7 +308,7 @@ func TestRepositoriesService_EditReleaseAsset(t *testing.T) { } func TestRepositoriesService_DeleteReleaseAsset(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -322,7 +322,7 @@ func TestRepositoriesService_DeleteReleaseAsset(t *testing.T) { } func TestRepositoriesService_UploadReleaseAsset(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1/assets", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 63f0fc6887d..97072478276 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListContributorsStats(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/contributors", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) { } func TestRepositoriesService_ListCommitActivity(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/commit_activity", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) { } func TestRepositoriesService_ListCodeFrequency(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/code_frequency", func(w http.ResponseWriter, r *http.Request) { @@ -131,7 +131,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) { } func TestRepositoriesService_Participation(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/participation", func(w http.ResponseWriter, r *http.Request) { @@ -181,7 +181,7 @@ func TestRepositoriesService_Participation(t *testing.T) { } func TestRepositoriesService_ListPunchCard(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/punch_card", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_statuses_test.go b/github/repos_statuses_test.go index b2c7db767c3..da0294bbd69 100644 --- a/github/repos_statuses_test.go +++ b/github/repos_statuses_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListStatuses(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/r/statuses", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListStatuses(t *testing.T) { } func TestRepositoriesService_ListStatuses_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListStatuses(context.Background(), "%", "r", "r", nil) @@ -45,7 +45,7 @@ func TestRepositoriesService_ListStatuses_invalidOwner(t *testing.T) { } func TestRepositoriesService_CreateStatus(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &RepoStatus{State: String("s"), TargetURL: String("t"), Description: String("d")} @@ -73,7 +73,7 @@ func TestRepositoriesService_CreateStatus(t *testing.T) { } func TestRepositoriesService_CreateStatus_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateStatus(context.Background(), "%", "r", "r", nil) @@ -81,7 +81,7 @@ func TestRepositoriesService_CreateStatus_invalidOwner(t *testing.T) { } func TestRepositoriesService_GetCombinedStatus(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/r/status", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_test.go b/github/repos_test.go index 897527f6296..2371e9e5fcb 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -16,7 +16,7 @@ import ( ) func TestRepositoriesService_List_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -38,7 +38,7 @@ func TestRepositoriesService_List_authenticatedUser(t *testing.T) { } func TestRepositoriesService_List_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -74,7 +74,7 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) { } func TestRepositoriesService_List_specifiedUser_type(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -102,7 +102,7 @@ func TestRepositoriesService_List_specifiedUser_type(t *testing.T) { } func TestRepositoriesService_List_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.List(context.Background(), "%", nil) @@ -110,7 +110,7 @@ func TestRepositoriesService_List_invalidUser(t *testing.T) { } func TestRepositoriesService_ListByOrg(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -137,7 +137,7 @@ func TestRepositoriesService_ListByOrg(t *testing.T) { } func TestRepositoriesService_ListByOrg_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListByOrg(context.Background(), "%", nil) @@ -145,7 +145,7 @@ func TestRepositoriesService_ListByOrg_invalidOrg(t *testing.T) { } func TestRepositoriesService_ListAll(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -169,7 +169,7 @@ func TestRepositoriesService_ListAll(t *testing.T) { } func TestRepositoriesService_Create_user(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Repository{Name: String("n")} @@ -198,7 +198,7 @@ func TestRepositoriesService_Create_user(t *testing.T) { } func TestRepositoriesService_Create_org(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Repository{Name: String("n")} @@ -227,7 +227,7 @@ func TestRepositoriesService_Create_org(t *testing.T) { } func TestRepositoriesService_Create_invalidOrg(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.Create(context.Background(), "%", nil) @@ -235,7 +235,7 @@ func TestRepositoriesService_Create_invalidOrg(t *testing.T) { } func TestRepositoriesService_Get(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -257,7 +257,7 @@ func TestRepositoriesService_Get(t *testing.T) { } func TestRepositoriesService_GetCodeOfConduct(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/community/code_of_conduct", func(w http.ResponseWriter, r *http.Request) { @@ -289,7 +289,7 @@ func TestRepositoriesService_GetCodeOfConduct(t *testing.T) { } func TestRepositoriesService_GetByID(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repositories/1", func(w http.ResponseWriter, r *http.Request) { @@ -310,7 +310,7 @@ func TestRepositoriesService_GetByID(t *testing.T) { } func TestRepositoriesService_Edit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() i := true @@ -339,7 +339,7 @@ func TestRepositoriesService_Edit(t *testing.T) { } func TestRepositoriesService_Delete(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -353,7 +353,7 @@ func TestRepositoriesService_Delete(t *testing.T) { } func TestRepositoriesService_Get_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.Get(context.Background(), "%", "r") @@ -361,7 +361,7 @@ func TestRepositoriesService_Get_invalidOwner(t *testing.T) { } func TestRepositoriesService_Edit_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.Edit(context.Background(), "%", "r", nil) @@ -369,7 +369,7 @@ func TestRepositoriesService_Edit_invalidOwner(t *testing.T) { } func TestRepositoriesService_ListContributors(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contributors", func(w http.ResponseWriter, r *http.Request) { @@ -394,7 +394,7 @@ func TestRepositoriesService_ListContributors(t *testing.T) { } func TestRepositoriesService_ListLanguages(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/languages", func(w http.ResponseWriter, r *http.Request) { @@ -414,7 +414,7 @@ func TestRepositoriesService_ListLanguages(t *testing.T) { } func TestRepositoriesService_ListTeams(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/teams", func(w http.ResponseWriter, r *http.Request) { @@ -436,7 +436,7 @@ func TestRepositoriesService_ListTeams(t *testing.T) { } func TestRepositoriesService_ListTags(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/tags", func(w http.ResponseWriter, r *http.Request) { @@ -468,7 +468,7 @@ func TestRepositoriesService_ListTags(t *testing.T) { } func TestRepositoriesService_ListBranches(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches", func(w http.ResponseWriter, r *http.Request) { @@ -491,7 +491,7 @@ func TestRepositoriesService_ListBranches(t *testing.T) { } func TestRepositoriesService_GetBranch(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) { @@ -522,7 +522,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) { } func TestRepositoriesService_GetBranchProtection(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) { @@ -575,7 +575,7 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) { } func TestRepositoriesService_UpdateBranchProtection(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &ProtectionRequest{ @@ -645,7 +645,7 @@ func TestRepositoriesService_UpdateBranchProtection(t *testing.T) { } func TestRepositoriesService_RemoveBranchProtection(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) { @@ -661,7 +661,7 @@ func TestRepositoriesService_RemoveBranchProtection(t *testing.T) { } func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Repositories.ListLanguages(context.Background(), "%", "%") @@ -669,7 +669,7 @@ func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) { } func TestRepositoriesService_License(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/license", func(w http.ResponseWriter, r *http.Request) { @@ -700,7 +700,7 @@ func TestRepositoriesService_License(t *testing.T) { } func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) { @@ -727,7 +727,7 @@ func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) { } func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks/contexts", func(w http.ResponseWriter, r *http.Request) { @@ -751,7 +751,7 @@ func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) { } func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -784,7 +784,7 @@ func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &PullRequestReviewsEnforcementUpdate{ @@ -829,7 +829,7 @@ func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -858,7 +858,7 @@ func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) { } func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -874,7 +874,7 @@ func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_GetAdminEnforcement(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -899,7 +899,7 @@ func TestRepositoriesService_GetAdminEnforcement(t *testing.T) { } func TestRepositoriesService_AddAdminEnforcement(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -923,7 +923,7 @@ func TestRepositoriesService_AddAdminEnforcement(t *testing.T) { } func TestRepositoriesService_RemoveAdminEnforcement(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -953,7 +953,7 @@ func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctio } func TestRepositoriesService_ListAllTopics(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -974,7 +974,7 @@ func TestRepositoriesService_ListAllTopics(t *testing.T) { } func TestRepositoriesService_ReplaceAllTopics(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index 95750a9b18c..ee3139cc21f 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListTrafficReferrers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/popular/referrers", func(w http.ResponseWriter, r *http.Request) { @@ -43,7 +43,7 @@ func TestRepositoriesService_ListTrafficReferrers(t *testing.T) { } func TestRepositoriesService_ListTrafficPaths(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/popular/paths", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestRepositoriesService_ListTrafficPaths(t *testing.T) { } func TestRepositoriesService_ListTrafficViews(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/views", func(w http.ResponseWriter, r *http.Request) { @@ -109,7 +109,7 @@ func TestRepositoriesService_ListTrafficViews(t *testing.T) { } func TestRepositoriesService_ListTrafficClones(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/clones", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/search_test.go b/github/search_test.go index 8b3ec66c004..fa0eb65510e 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -15,7 +15,7 @@ import ( ) func TestSearchService_Repositories(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/search/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -48,7 +48,7 @@ func TestSearchService_Repositories(t *testing.T) { } func TestSearchService_Commits(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/search/commits", func(w http.ResponseWriter, r *http.Request) { @@ -79,7 +79,7 @@ func TestSearchService_Commits(t *testing.T) { } func TestSearchService_Issues(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) { @@ -112,7 +112,7 @@ func TestSearchService_Issues(t *testing.T) { } func TestSearchService_Issues_withQualifiers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) { @@ -141,7 +141,7 @@ func TestSearchService_Issues_withQualifiers(t *testing.T) { } func TestSearchService_Users(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/search/users", func(w http.ResponseWriter, r *http.Request) { @@ -174,7 +174,7 @@ func TestSearchService_Users(t *testing.T) { } func TestSearchService_Code(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/search/code", func(w http.ResponseWriter, r *http.Request) { @@ -207,7 +207,7 @@ func TestSearchService_Code(t *testing.T) { } func TestSearchService_CodeTextMatch(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/search/code", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_administration_test.go b/github/users_administration_test.go index 1ea5d55c65c..829143c8a27 100644 --- a/github/users_administration_test.go +++ b/github/users_administration_test.go @@ -12,7 +12,7 @@ import ( ) func TestUsersService_PromoteSiteAdmin(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/site_admin", func(w http.ResponseWriter, r *http.Request) { @@ -27,7 +27,7 @@ func TestUsersService_PromoteSiteAdmin(t *testing.T) { } func TestUsersService_DemoteSiteAdmin(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/site_admin", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestUsersService_DemoteSiteAdmin(t *testing.T) { } func TestUsersService_Suspend(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestUsersService_Suspend(t *testing.T) { } func TestUsersService_Unsuspend(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_blocking_test.go b/github/users_blocking_test.go index c5192502c30..6977c9198d2 100644 --- a/github/users_blocking_test.go +++ b/github/users_blocking_test.go @@ -14,7 +14,7 @@ import ( ) func TestUsersService_ListBlockedUsers(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestUsersService_ListBlockedUsers(t *testing.T) { } func TestUsersService_IsBlocked(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestUsersService_IsBlocked(t *testing.T) { } func TestUsersService_BlockUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func TestUsersService_BlockUser(t *testing.T) { } func TestUsersService_UnblockUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_emails_test.go b/github/users_emails_test.go index 1be1cb589c5..925b2f80428 100644 --- a/github/users_emails_test.go +++ b/github/users_emails_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListEmails(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/emails", func(w http.ResponseWriter, r *http.Request) { @@ -41,7 +41,7 @@ func TestUsersService_ListEmails(t *testing.T) { } func TestUsersService_AddEmails(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := []string{"new@example.com"} @@ -73,7 +73,7 @@ func TestUsersService_AddEmails(t *testing.T) { } func TestUsersService_DeleteEmails(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := []string{"user@example.com"} diff --git a/github/users_followers_test.go b/github/users_followers_test.go index 69e8493d75a..f89e9b1ca60 100644 --- a/github/users_followers_test.go +++ b/github/users_followers_test.go @@ -14,7 +14,7 @@ import ( ) func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/followers", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) { } func TestUsersService_ListFollowers_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/followers", func(w http.ResponseWriter, r *http.Request) { @@ -56,7 +56,7 @@ func TestUsersService_ListFollowers_specifiedUser(t *testing.T) { } func TestUsersService_ListFollowers_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Users.ListFollowers(context.Background(), "%", nil) @@ -64,7 +64,7 @@ func TestUsersService_ListFollowers_invalidUser(t *testing.T) { } func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/following", func(w http.ResponseWriter, r *http.Request) { @@ -86,7 +86,7 @@ func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) { } func TestUsersService_ListFollowing_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following", func(w http.ResponseWriter, r *http.Request) { @@ -106,7 +106,7 @@ func TestUsersService_ListFollowing_specifiedUser(t *testing.T) { } func TestUsersService_ListFollowing_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Users.ListFollowing(context.Background(), "%", nil) @@ -114,7 +114,7 @@ func TestUsersService_ListFollowing_invalidUser(t *testing.T) { } func TestUsersService_IsFollowing_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -132,7 +132,7 @@ func TestUsersService_IsFollowing_authenticatedUser(t *testing.T) { } func TestUsersService_IsFollowing_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -150,7 +150,7 @@ func TestUsersService_IsFollowing_specifiedUser(t *testing.T) { } func TestUsersService_IsFollowing_false(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -168,7 +168,7 @@ func TestUsersService_IsFollowing_false(t *testing.T) { } func TestUsersService_IsFollowing_error(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -186,7 +186,7 @@ func TestUsersService_IsFollowing_error(t *testing.T) { } func TestUsersService_IsFollowing_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Users.IsFollowing(context.Background(), "%", "%") @@ -194,7 +194,7 @@ func TestUsersService_IsFollowing_invalidUser(t *testing.T) { } func TestUsersService_Follow(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) { @@ -208,7 +208,7 @@ func TestUsersService_Follow(t *testing.T) { } func TestUsersService_Follow_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Users.Follow(context.Background(), "%") @@ -216,7 +216,7 @@ func TestUsersService_Follow_invalidUser(t *testing.T) { } func TestUsersService_Unfollow(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) { @@ -230,7 +230,7 @@ func TestUsersService_Unfollow(t *testing.T) { } func TestUsersService_Unfollow_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, err := client.Users.Unfollow(context.Background(), "%") diff --git a/github/users_gpg_keys_test.go b/github/users_gpg_keys_test.go index 93bbab68c9c..08f33b179ed 100644 --- a/github/users_gpg_keys_test.go +++ b/github/users_gpg_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListGPGKeys_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestUsersService_ListGPGKeys_authenticatedUser(t *testing.T) { } func TestUsersService_ListGPGKeys_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/gpg_keys", func(w http.ResponseWriter, r *http.Request) { @@ -59,7 +59,7 @@ func TestUsersService_ListGPGKeys_specifiedUser(t *testing.T) { } func TestUsersService_ListGPGKeys_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Users.ListGPGKeys(context.Background(), "%", nil) @@ -67,7 +67,7 @@ func TestUsersService_ListGPGKeys_invalidUser(t *testing.T) { } func TestUsersService_GetGPGKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -88,7 +88,7 @@ func TestUsersService_GetGPGKey(t *testing.T) { } func TestUsersService_CreateGPGKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := ` @@ -127,7 +127,7 @@ mQINBFcEd9kBEACo54TDbGhKlXKWMvJgecEUKPPcv7XdnpKdGb3LRw5MvFwT0V0f } func TestUsersService_DeleteGPGKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_keys_test.go b/github/users_keys_test.go index 349c9fd9849..40a0e0127a7 100644 --- a/github/users_keys_test.go +++ b/github/users_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/keys", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { } func TestUsersService_ListKeys_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u/keys", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestUsersService_ListKeys_specifiedUser(t *testing.T) { } func TestUsersService_ListKeys_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Users.ListKeys(context.Background(), "%", nil) @@ -65,7 +65,7 @@ func TestUsersService_ListKeys_invalidUser(t *testing.T) { } func TestUsersService_GetKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -85,7 +85,7 @@ func TestUsersService_GetKey(t *testing.T) { } func TestUsersService_CreateKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -114,7 +114,7 @@ func TestUsersService_CreateKey(t *testing.T) { } func TestUsersService_DeleteKey(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_test.go b/github/users_test.go index 5b5d48b6303..c0c13d6d55b 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -57,7 +57,7 @@ func TestUser_marshall(t *testing.T) { } func TestUsersService_Get_authenticatedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) { @@ -77,7 +77,7 @@ func TestUsersService_Get_authenticatedUser(t *testing.T) { } func TestUsersService_Get_specifiedUser(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users/u", func(w http.ResponseWriter, r *http.Request) { @@ -97,7 +97,7 @@ func TestUsersService_Get_specifiedUser(t *testing.T) { } func TestUsersService_Get_invalidUser(t *testing.T) { - client, teardown := setup() + _, _, client, teardown := setup() defer teardown() _, _, err := client.Users.Get(context.Background(), "%") @@ -105,7 +105,7 @@ func TestUsersService_Get_invalidUser(t *testing.T) { } func TestUsersService_GetByID(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/1", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestUsersService_GetByID(t *testing.T) { } func TestUsersService_Edit(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() input := &User{Name: String("n")} @@ -154,7 +154,7 @@ func TestUsersService_Edit(t *testing.T) { } func TestUsersService_ListAll(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) { @@ -176,7 +176,7 @@ func TestUsersService_ListAll(t *testing.T) { } func TestUsersService_ListInvitations(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) { @@ -197,7 +197,7 @@ func TestUsersService_ListInvitations(t *testing.T) { } func TestUsersService_ListInvitations_withOptions(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) { @@ -215,7 +215,7 @@ func TestUsersService_ListInvitations_withOptions(t *testing.T) { } } func TestUsersService_AcceptInvitation(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) { @@ -230,7 +230,7 @@ func TestUsersService_AcceptInvitation(t *testing.T) { } func TestUsersService_DeclineInvitation(t *testing.T) { - client, teardown := setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/test/integration/doc.go b/test/integration/doc.go index 5ee470c50c8..d25f63140ca 100644 --- a/test/integration/doc.go +++ b/test/integration/doc.go @@ -6,6 +6,6 @@ // Package integration contains integration tests. // // These tests call the live GitHub API, and therefore require a little more -// setup to run. See https://github.com/google/go-github/tree/master/test#integration +// setup() to run. See https://github.com/google/go-github/tree/master/test#integration // for more information. package integration From 576bc4e5f4adc475b1c5ed8a71157fb3f316f8e5 Mon Sep 17 00:00:00 2001 From: Chris King Date: Sat, 28 Oct 2017 23:26:52 +0200 Subject: [PATCH 03/13] fixes comments that got caught in the find replace crossfire --- github/github_test.go | 2 +- test/integration/doc.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/github/github_test.go b/github/github_test.go index c20f7bc8e66..1486c87cb1a 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -28,7 +28,7 @@ const ( baseURLPath = "/api-v3" ) -// setup() sets up a test HTTP server along with a github.Client that is +// setup sets up a test HTTP server along with a github.Client that is // configured to talk to that test server. Tests should register handlers on // mux which provide mock responses for the API method being tested. func setup() (string, *http.ServeMux, *Client, func()) { diff --git a/test/integration/doc.go b/test/integration/doc.go index d25f63140ca..5ee470c50c8 100644 --- a/test/integration/doc.go +++ b/test/integration/doc.go @@ -6,6 +6,6 @@ // Package integration contains integration tests. // // These tests call the live GitHub API, and therefore require a little more -// setup() to run. See https://github.com/google/go-github/tree/master/test#integration +// setup to run. See https://github.com/google/go-github/tree/master/test#integration // for more information. package integration From cb3b763ccb2d8124ffe28d9ee5c44712b57bd412 Mon Sep 17 00:00:00 2001 From: Chris King Date: Tue, 31 Oct 2017 12:21:16 +0100 Subject: [PATCH 04/13] merges changes from master --- CONTRIBUTING.md | 2 +- github/apps.go | 131 ++++++++++++++++++++++++++++++- github/apps_installation.go | 27 +++++++ github/apps_installation_test.go | 25 ++++++ github/apps_test.go | 110 ++++++++++++++++++++++++++ github/github-accessors.go | 72 +++++++++++++++++ github/github.go | 31 ++++++++ github/github_test.go | 35 +++++++++ github/pulls.go | 8 +- github/pulls_test.go | 24 +++--- github/repos_commits.go | 29 ++++++- github/repos_commits_test.go | 58 ++++++++++++++ 12 files changed, 533 insertions(+), 19 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index efefdc54713..bda2562f310 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ again. [forking]: https://help.github.com/articles/fork-a-repo [golint]: https://github.com/golang/lint -[golint readme]: https://github.com/golang/lint/blob/master/README +[golint readme]: https://github.com/golang/lint/blob/master/README.md [gocov]: https://github.com/axw/gocov [gocov-html]: https://github.com/matm/gocov-html [well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html diff --git a/github/apps.go b/github/apps.go index ff3389382ee..a83ea7c2ecb 100644 --- a/github/apps.go +++ b/github/apps.go @@ -5,7 +5,11 @@ package github -import "context" +import ( + "context" + "fmt" + "time" +) // AppsService provides access to the installation related functions // in the GitHub API. @@ -13,6 +17,57 @@ import "context" // GitHub API docs: https://developer.github.com/v3/apps/ type AppsService service +// App represents a GitHub App. +type App struct { + ID *int `json:"id,omitempty"` + Owner *User `json:"owner,omitempty"` + Name *string `json:"name,omitempty"` + Description *string `json:"description,omitempty"` + ExternalURL *string `json:"external_url,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` +} + +// InstallationToken represents an installation token. +type InstallationToken struct { + Token *string `json:"token,omitempty"` + ExpiresAt *time.Time `json:"expires_at,omitempty"` +} + +// Get a single GitHub App. Passing the empty string will get +// the authenticated GitHub App. +// +// Note: appSlug is just the URL-friendly name of your GitHub App. +// You can find this on the settings page for your GitHub App +// (e.g., https://github.com/settings/apps/:app_slug). +// +// GitHub API docs: https://developer.github.com/v3/apps/#get-a-single-github-app +func (s *AppsService) Get(ctx context.Context, appSlug string) (*App, *Response, error) { + var u string + if appSlug != "" { + u = fmt.Sprintf("apps/%v", appSlug) + } else { + u = "app" + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeIntegrationPreview) + + app := new(App) + resp, err := s.client.Do(ctx, req, app) + if err != nil { + return nil, resp, err + } + + return app, resp, nil +} + // ListInstallations lists the installations that the current GitHub App has. // // GitHub API docs: https://developer.github.com/v3/apps/#find-installations @@ -38,3 +93,77 @@ func (s *AppsService) ListInstallations(ctx context.Context, opt *ListOptions) ( return i, resp, nil } + +// GetInstallation returns the specified installation. +// +// GitHub API docs: https://developer.github.com/v3/apps/#get-a-single-installation +func (s *AppsService) GetInstallation(ctx context.Context, id int) (*Installation, *Response, error) { + u := fmt.Sprintf("app/installations/%v", id) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeIntegrationPreview) + + i := new(Installation) + resp, err := s.client.Do(ctx, req, i) + if err != nil { + return nil, resp, err + } + + return i, resp, nil +} + +// ListUserInstallations lists installations that are accessible to the authenticated user. +// +// GitHub API docs: https://developer.github.com/v3/apps/#list-installations-for-user +func (s *AppsService) ListUserInstallations(ctx context.Context, opt *ListOptions) ([]*Installation, *Response, error) { + u, err := addOptions("user/installations", opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeIntegrationPreview) + + var i struct { + Installations []*Installation `json:"installations"` + } + resp, err := s.client.Do(ctx, req, &i) + if err != nil { + return nil, resp, err + } + + return i.Installations, resp, nil +} + +// CreateInstallationToken creates a new installation token. +// +// GitHub API docs: https://developer.github.com/v3/apps/#create-a-new-installation-token +func (s *AppsService) CreateInstallationToken(ctx context.Context, id int) (*InstallationToken, *Response, error) { + u := fmt.Sprintf("installations/%v/access_tokens", id) + + req, err := s.client.NewRequest("POST", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches. + req.Header.Set("Accept", mediaTypeIntegrationPreview) + + t := new(InstallationToken) + resp, err := s.client.Do(ctx, req, t) + if err != nil { + return nil, resp, err + } + + return t, resp, nil +} diff --git a/github/apps_installation.go b/github/apps_installation.go index 5c932919fff..ccac316c4ec 100644 --- a/github/apps_installation.go +++ b/github/apps_installation.go @@ -51,6 +51,33 @@ func (s *AppsService) ListRepos(ctx context.Context, opt *ListOptions) ([]*Repos return r.Repositories, resp, nil } +// ListUserRepos lists repositories that are accessible +// to the authenticated user for an installation. +// +// GitHub API docs: https://developer.github.com/v3/apps/installations/#list-repositories-accessible-to-the-user-for-an-installation +func (s *AppsService) ListUserRepos(ctx context.Context, id int, opt *ListOptions) ([]*Repository, *Response, error) { + u := fmt.Sprintf("user/installations/%v/repositories", id) + u, err := addOptions(u, opt) + if err != nil { + return nil, nil, err + } + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + var r struct { + Repositories []*Repository `json:"repositories"` + } + resp, err := s.client.Do(ctx, req, &r) + if err != nil { + return nil, resp, err + } + + return r.Repositories, resp, nil +} + // AddRepository adds a single repository to an installation. // // GitHub API docs: https://developer.github.com/v3/apps/installations/#add-repository-to-installation diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index 9937f8e66f9..6ccaed3ceb0 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -39,6 +39,31 @@ func TestAppsService_ListRepos(t *testing.T) { } } +func TestAppsService_ListUserRepos(t *testing.T) { + _, mux, client, teardown := setup() + defer teardown() + + mux.HandleFunc("/user/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testFormValues(t, r, values{ + "page": "1", + "per_page": "2", + }) + fmt.Fprint(w, `{"repositories": [{"id":1}]}`) + }) + + opt := &ListOptions{Page: 1, PerPage: 2} + repositories, _, err := client.Apps.ListUserRepos(context.Background(), 1, opt) + if err != nil { + t.Errorf("Apps.ListUserRepos returned error: %v", err) + } + + want := []*Repository{{ID: Int(1)}} + if !reflect.DeepEqual(repositories, want) { + t.Errorf("Apps.ListUserRepos returned %+v, want %+v", repositories, want) + } +} + func TestAppsService_AddRepository(t *testing.T) { _, mux, client, teardown := setup() defer teardown() diff --git a/github/apps_test.go b/github/apps_test.go index 3d1deb6ec4d..f331cf1c4aa 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -13,6 +13,48 @@ import ( "testing" ) +func TestAppsService_Get_authenticatedApp(t *testing.T) { + _, mux, client, teardown := setup() + defer teardown() + + mux.HandleFunc("/app", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeIntegrationPreview) + fmt.Fprint(w, `{"id":1}`) + }) + + app, _, err := client.Apps.Get(context.Background(), "") + if err != nil { + t.Errorf("Apps.Get returned error: %v", err) + } + + want := &App{ID: Int(1)} + if !reflect.DeepEqual(app, want) { + t.Errorf("Apps.Get returned %+v, want %+v", app, want) + } +} + +func TestAppsService_Get_specifiedApp(t *testing.T) { + _, mux, client, teardown := setup() + defer teardown() + + mux.HandleFunc("/apps/a", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeIntegrationPreview) + fmt.Fprint(w, `{"html_url":"https://github.com/apps/a"}`) + }) + + app, _, err := client.Apps.Get(context.Background(), "a") + if err != nil { + t.Errorf("Apps.Get returned error: %v", err) + } + + want := &App{HTMLURL: String("https://github.com/apps/a")} + if !reflect.DeepEqual(app, want) { + t.Errorf("Apps.Get returned %+v, want %+v", *app.HTMLURL, *want.HTMLURL) + } +} + func TestAppsService_ListInstallations(t *testing.T) { _, mux, client, teardown := setup() defer teardown() @@ -38,3 +80,71 @@ func TestAppsService_ListInstallations(t *testing.T) { t.Errorf("Apps.ListInstallations returned %+v, want %+v", installations, want) } } + +func TestAppsService_GetInstallation(t *testing.T) { + _, mux, client, teardown := setup() + defer teardown() + + mux.HandleFunc("/app/installations/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeIntegrationPreview) + fmt.Fprint(w, `{"id":1}`) + }) + + installation, _, err := client.Apps.GetInstallation(context.Background(), 1) + if err != nil { + t.Errorf("Apps.GetInstallation returned error: %v", err) + } + + want := &Installation{ID: Int(1)} + if !reflect.DeepEqual(installation, want) { + t.Errorf("Apps.GetInstallation returned %+v, want %+v", installation, want) + } +} + +func TestAppsService_ListUserInstallations(t *testing.T) { + _, mux, client, teardown := setup() + defer teardown() + + mux.HandleFunc("/user/installations", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeIntegrationPreview) + testFormValues(t, r, values{ + "page": "1", + "per_page": "2", + }) + fmt.Fprint(w, `{"installations":[{"id":1}]}`) + }) + + opt := &ListOptions{Page: 1, PerPage: 2} + installations, _, err := client.Apps.ListUserInstallations(context.Background(), opt) + if err != nil { + t.Errorf("Apps.ListUserInstallations returned error: %v", err) + } + + want := []*Installation{{ID: Int(1)}} + if !reflect.DeepEqual(installations, want) { + t.Errorf("Apps.ListUserInstallations returned %+v, want %+v", installations, want) + } +} + +func TestAppsService_CreateInstallationToken(t *testing.T) { + _, mux, client, teardown := setup() + defer teardown() + + mux.HandleFunc("/installations/1/access_tokens", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "POST") + testHeader(t, r, "Accept", mediaTypeIntegrationPreview) + fmt.Fprint(w, `{"token":"t"}`) + }) + + token, _, err := client.Apps.CreateInstallationToken(context.Background(), 1) + if err != nil { + t.Errorf("Apps.CreateInstallationToken returned error: %v", err) + } + + want := &InstallationToken{Token: String("t")} + if !reflect.DeepEqual(token, want) { + t.Errorf("Apps.CreateInstallationToken returned %+v, want %+v", token, want) + } +} diff --git a/github/github-accessors.go b/github/github-accessors.go index 6da009baf1f..4e0ce60017d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -36,6 +36,62 @@ func (a *APIMeta) GetVerifiablePasswordAuthentication() bool { return *a.VerifiablePasswordAuthentication } +// GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. +func (a *App) GetCreatedAt() time.Time { + if a == nil || a.CreatedAt == nil { + return time.Time{} + } + return *a.CreatedAt +} + +// GetDescription returns the Description field if it's non-nil, zero value otherwise. +func (a *App) GetDescription() string { + if a == nil || a.Description == nil { + return "" + } + return *a.Description +} + +// GetExternalURL returns the ExternalURL field if it's non-nil, zero value otherwise. +func (a *App) GetExternalURL() string { + if a == nil || a.ExternalURL == nil { + return "" + } + return *a.ExternalURL +} + +// GetHTMLURL returns the HTMLURL field if it's non-nil, zero value otherwise. +func (a *App) GetHTMLURL() string { + if a == nil || a.HTMLURL == nil { + return "" + } + return *a.HTMLURL +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (a *App) GetID() int { + if a == nil || a.ID == nil { + return 0 + } + return *a.ID +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (a *App) GetName() string { + if a == nil || a.Name == nil { + return "" + } + return *a.Name +} + +// GetUpdatedAt returns the UpdatedAt field if it's non-nil, zero value otherwise. +func (a *App) GetUpdatedAt() time.Time { + if a == nil || a.UpdatedAt == nil { + return time.Time{} + } + return *a.UpdatedAt +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (a *Authorization) GetCreatedAt() Timestamp { if a == nil || a.CreatedAt == nil { @@ -2036,6 +2092,22 @@ func (i *InstallationRepositoriesEvent) GetRepositorySelection() string { return *i.RepositorySelection } +// GetExpiresAt returns the ExpiresAt field if it's non-nil, zero value otherwise. +func (i *InstallationToken) GetExpiresAt() time.Time { + if i == nil || i.ExpiresAt == nil { + return time.Time{} + } + return *i.ExpiresAt +} + +// GetToken returns the Token field if it's non-nil, zero value otherwise. +func (i *InstallationToken) GetToken() string { + if i == nil || i.Token == nil { + return "" + } + return *i.Token +} + // GetCreatedAt returns the CreatedAt field if it's non-nil, zero value otherwise. func (i *Invitation) GetCreatedAt() time.Time { if i == nil || i.CreatedAt == nil { diff --git a/github/github.go b/github/github.go index b33f70a412e..87af91de275 100644 --- a/github/github.go +++ b/github/github.go @@ -235,6 +235,37 @@ func NewClient(httpClient *http.Client) *Client { return c } +// NewEnterpriseClient returns a new GitHub API client with provided +// base URL and upload URL (often the same URL). +// If either URL does not have a trailing slash, one is added automatically. +// If a nil httpClient is provided, http.DefaultClient will be used. +// +// Note that NewEnterpriseClient is a convenience helper only; +// its behavior is equivalent to using NewClient, followed by setting +// the BaseURL and UploadURL fields. +func NewEnterpriseClient(baseURL, uploadURL string, httpClient *http.Client) (*Client, error) { + baseEndpoint, err := url.Parse(baseURL) + if err != nil { + return nil, err + } + if !strings.HasSuffix(baseEndpoint.Path, "/") { + baseEndpoint.Path += "/" + } + + uploadEndpoint, err := url.Parse(uploadURL) + if err != nil { + return nil, err + } + if !strings.HasSuffix(uploadEndpoint.Path, "/") { + uploadEndpoint.Path += "/" + } + + c := NewClient(httpClient) + c.BaseURL = baseEndpoint + c.UploadURL = uploadEndpoint + return c, nil +} + // NewRequest creates an API request. A relative URL can be provided in urlStr, // in which case it is resolved relative to the BaseURL of the Client. // Relative URLs should always be specified without a preceding slash. If diff --git a/github/github_test.go b/github/github_test.go index 1486c87cb1a..0832613c83f 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -172,6 +172,41 @@ func TestNewClient(t *testing.T) { } } +func TestNewEnterpriseClient(t *testing.T) { + baseURL := "https://custom-url/" + uploadURL := "https://custom-upload-url/" + c, err := NewEnterpriseClient(baseURL, uploadURL, nil) + if err != nil { + t.Fatalf("NewEnterpriseClient returned unexpected error: %v", err) + } + + if got, want := c.BaseURL.String(), baseURL; got != want { + t.Errorf("NewClient BaseURL is %v, want %v", got, want) + } + if got, want := c.UploadURL.String(), uploadURL; got != want { + t.Errorf("NewClient UploadURL is %v, want %v", got, want) + } +} + +func TestNewEnterpriseClient_addsTrailingSlashToURLs(t *testing.T) { + baseURL := "https://custom-url" + uploadURL := "https://custom-upload-url" + formattedBaseURL := baseURL + "/" + formattedUploadURL := uploadURL + "/" + + c, err := NewEnterpriseClient(baseURL, uploadURL, nil) + if err != nil { + t.Fatalf("NewEnterpriseClient returned unexpected error: %v", err) + } + + if got, want := c.BaseURL.String(), formattedBaseURL; got != want { + t.Errorf("NewClient BaseURL is %v, want %v", got, want) + } + if got, want := c.UploadURL.String(), formattedUploadURL; got != want { + t.Errorf("NewClient UploadURL is %v, want %v", got, want) + } +} + // Ensure that length of Client.rateLimits is the same as number of fields in RateLimits struct. func TestClient_rateLimits(t *testing.T) { if got, want := len(Client{}.rateLimits), reflect.TypeOf(RateLimits{}).NumField(); got != want { diff --git a/github/pulls.go b/github/pulls.go index bc46081fca6..6681c8b21b0 100644 --- a/github/pulls.go +++ b/github/pulls.go @@ -138,7 +138,7 @@ func (s *PullRequestsService) Get(ctx context.Context, owner string, repo string return pull, resp, nil } -// GetRaw gets raw (diff or patch) format of a pull request. +// GetRaw gets a single pull request in raw (diff or patch) format. func (s *PullRequestsService) GetRaw(ctx context.Context, owner string, repo string, number int, opt RawOptions) (string, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) @@ -155,13 +155,13 @@ func (s *PullRequestsService) GetRaw(ctx context.Context, owner string, repo str return "", nil, fmt.Errorf("unsupported raw type %d", opt.Type) } - ret := new(bytes.Buffer) - resp, err := s.client.Do(ctx, req, ret) + var buf bytes.Buffer + resp, err := s.client.Do(ctx, req, &buf) if err != nil { return "", resp, err } - return ret.String(), resp, nil + return buf.String(), resp, nil } // NewPullRequest represents a new pull request to be created. diff --git a/github/pulls_test.go b/github/pulls_test.go index 9ab8000c427..bf82cd5e6ab 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -73,9 +73,10 @@ func TestPullRequestsService_Get(t *testing.T) { } } -func TestPullRequestsService_GetRawDiff(t *testing.T) { +func TestPullRequestsService_GetRaw_diff(t *testing.T) { _, mux, client, teardown := setup() defer teardown() + const rawStr = "@@diff content" mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -84,19 +85,20 @@ func TestPullRequestsService_GetRawDiff(t *testing.T) { fmt.Fprint(w, rawStr) }) - ret, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Diff}) + got, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Diff}) if err != nil { t.Fatalf("PullRequests.GetRaw returned error: %v", err) } - - if ret != rawStr { - t.Errorf("PullRequests.GetRaw returned %s want %s", ret, rawStr) + want := rawStr + if got != want { + t.Errorf("PullRequests.GetRaw returned %s want %s", got, want) } } -func TestPullRequestsService_GetRawPatch(t *testing.T) { +func TestPullRequestsService_GetRaw_patch(t *testing.T) { _, mux, client, teardown := setup() defer teardown() + const rawStr = "@@patch content" mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -105,17 +107,17 @@ func TestPullRequestsService_GetRawPatch(t *testing.T) { fmt.Fprint(w, rawStr) }) - ret, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Patch}) + got, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{Patch}) if err != nil { t.Fatalf("PullRequests.GetRaw returned error: %v", err) } - - if ret != rawStr { - t.Errorf("PullRequests.GetRaw returned %s want %s", ret, rawStr) + want := rawStr + if got != want { + t.Errorf("PullRequests.GetRaw returned %s want %s", got, want) } } -func TestPullRequestsService_GetRawInvalid(t *testing.T) { +func TestPullRequestsService_GetRaw_invalid(t *testing.T) { _, _, client, teardown := setup() defer teardown() diff --git a/github/repos_commits.go b/github/repos_commits.go index 4451b6bb465..0484737342c 100644 --- a/github/repos_commits.go +++ b/github/repos_commits.go @@ -140,10 +140,9 @@ func (s *RepositoriesService) ListCommits(ctx context.Context, owner, repo strin } // GetCommit fetches the specified commit, including all details about it. -// todo: support media formats - https://github.com/google/go-github/issues/6 // // GitHub API docs: https://developer.github.com/v3/repos/commits/#get-a-single-commit -// See also: https://developer.github.com//v3/git/commits/#get-a-single-commit provides the same functionality +// See also: https://developer.github.com/v3/git/commits/#get-a-single-commit provides the same functionality func (s *RepositoriesService) GetCommit(ctx context.Context, owner, repo, sha string) (*RepositoryCommit, *Response, error) { u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha) @@ -164,6 +163,32 @@ func (s *RepositoriesService) GetCommit(ctx context.Context, owner, repo, sha st return commit, resp, nil } +// GetCommitRaw fetches the specified commit in raw (diff or patch) format. +func (s *RepositoriesService) GetCommitRaw(ctx context.Context, owner string, repo string, sha string, opt RawOptions) (string, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/commits/%v", owner, repo, sha) + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return "", nil, err + } + + switch opt.Type { + case Diff: + req.Header.Set("Accept", mediaTypeV3Diff) + case Patch: + req.Header.Set("Accept", mediaTypeV3Patch) + default: + return "", nil, fmt.Errorf("unsupported raw type %d", opt.Type) + } + + var buf bytes.Buffer + resp, err := s.client.Do(ctx, req, &buf) + if err != nil { + return "", resp, err + } + + return buf.String(), resp, nil +} + // GetCommitSHA1 gets the SHA-1 of a commit reference. If a last-known SHA1 is // supplied and no new commits have occurred, a 304 Unmodified response is returned. // diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 6f4fe94a269..27cdc175d9d 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -10,6 +10,7 @@ import ( "fmt" "net/http" "reflect" + "strings" "testing" "time" ) @@ -126,6 +127,63 @@ func TestRepositoriesService_GetCommit(t *testing.T) { } } +func TestRepositoriesService_GetCommitRaw_diff(t *testing.T) { + _, mux, client, teardown := setup() + defer teardown() + + const rawStr = "@@diff content" + + mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeV3Diff) + fmt.Fprint(w, rawStr) + }) + + got, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{Type: Diff}) + if err != nil { + t.Fatalf("Repositories.GetCommitRaw returned error: %v", err) + } + want := rawStr + if got != want { + t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want) + } +} + +func TestRepositoriesService_GetCommitRaw_patch(t *testing.T) { + _, mux, client, teardown := setup() + defer teardown() + + const rawStr = "@@patch content" + + mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypeV3Patch) + fmt.Fprint(w, rawStr) + }) + + got, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{Type: Patch}) + if err != nil { + t.Fatalf("Repositories.GetCommitRaw returned error: %v", err) + } + want := rawStr + if got != want { + t.Errorf("Repositories.GetCommitRaw returned %s want %s", got, want) + } +} + +func TestRepositoriesService_GetCommitRaw_invalid(t *testing.T) { + _, _, client, teardown := setup() + defer teardown() + + _, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{100}) + if err == nil { + t.Fatal("Repositories.GetCommitRaw should return error") + } + if !strings.Contains(err.Error(), "unsupported raw type") { + t.Error("Repositories.GetCommitRaw should return unsupported raw type error") + } +} + func TestRepositoriesService_GetCommitSHA1(t *testing.T) { _, mux, client, teardown := setup() defer teardown() From c20a30e9e1d8725e7a2c3f931a1a200e3f167a7c Mon Sep 17 00:00:00 2001 From: Chris King Date: Tue, 31 Oct 2017 12:21:52 +0100 Subject: [PATCH 05/13] removes unintentional comment change --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index bda2562f310..8489bc1bde1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ again. issue that you are planning to work on that bug or feature so that it can be assigned to you. - 1. Follow the normal process of [forking][] the project, and setup() a new + 1. Follow the normal process of [forking][] the project, and a new branch to work in. It's important that each group of changes be done in separate branches in order to ensure that a pull request only includes the commits related to that bug or feature. From 52b77f979011203c0473017ffc338805df2f9ef7 Mon Sep 17 00:00:00 2001 From: Chris King Date: Thu, 16 Nov 2017 21:29:00 +0100 Subject: [PATCH 06/13] removes global vars from merged tests --- github/admin_stats_test.go | 2 +- github/apps_marketplace_test.go | 16 ++++++++-------- github/orgs_teams_test.go | 4 ++-- github/repos_test.go | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/github/admin_stats_test.go b/github/admin_stats_test.go index d2d979a10e9..e5ec5db2b9b 100644 --- a/github/admin_stats_test.go +++ b/github/admin_stats_test.go @@ -9,7 +9,7 @@ import ( ) func TestAdminService_GetAdminStats(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/enterprise/stats/all", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/apps_marketplace_test.go b/github/apps_marketplace_test.go index 151a72179cb..13c91613f3e 100644 --- a/github/apps_marketplace_test.go +++ b/github/apps_marketplace_test.go @@ -14,7 +14,7 @@ import ( ) func TestMarketplaceService_ListPlans(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/plans", func(w http.ResponseWriter, r *http.Request) { @@ -41,7 +41,7 @@ func TestMarketplaceService_ListPlans(t *testing.T) { } func TestMarketplaceService_Stubbed_ListPlans(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/stubbed/plans", func(w http.ResponseWriter, r *http.Request) { @@ -64,7 +64,7 @@ func TestMarketplaceService_Stubbed_ListPlans(t *testing.T) { } func TestMarketplaceService_ListPlanAccountsForPlan(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/plans/1/accounts", func(w http.ResponseWriter, r *http.Request) { @@ -87,7 +87,7 @@ func TestMarketplaceService_ListPlanAccountsForPlan(t *testing.T) { } func TestMarketplaceService_Stubbed_ListPlanAccountsForPlan(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/stubbed/plans/1/accounts", func(w http.ResponseWriter, r *http.Request) { @@ -110,7 +110,7 @@ func TestMarketplaceService_Stubbed_ListPlanAccountsForPlan(t *testing.T) { } func TestMarketplaceService_ListPlanAccountsForAccount(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/accounts/1", func(w http.ResponseWriter, r *http.Request) { @@ -133,7 +133,7 @@ func TestMarketplaceService_ListPlanAccountsForAccount(t *testing.T) { } func TestMarketplaceService_Stubbed_ListPlanAccountsForAccount(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/stubbed/accounts/1", func(w http.ResponseWriter, r *http.Request) { @@ -156,7 +156,7 @@ func TestMarketplaceService_Stubbed_ListPlanAccountsForAccount(t *testing.T) { } func TestMarketplaceService_ListMarketplacePurchasesForUser(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/marketplace_purchases", func(w http.ResponseWriter, r *http.Request) { @@ -179,7 +179,7 @@ func TestMarketplaceService_ListMarketplacePurchasesForUser(t *testing.T) { } func TestMarketplaceService_Stubbed_ListMarketplacePurchasesForUser(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/user/marketplace_purchases/stubbed", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 43b36122c08..059a5257890 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -69,7 +69,7 @@ func TestOrganizationsService_GetTeam(t *testing.T) { } func TestOrganizationService_GetTeam_nestedTeams(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { @@ -176,7 +176,7 @@ func TestOrganizationsService_DeleteTeam(t *testing.T) { } func TestOrganizationsService_ListChildTeams(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/teams", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_test.go b/github/repos_test.go index d956d91e5eb..a9b06c2759c 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -975,7 +975,7 @@ func TestRepositoriesService_ListAllTopics(t *testing.T) { } func TestRepositoriesService_ListAllTopics_emptyTopics(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -1017,7 +1017,7 @@ func TestRepositoriesService_ReplaceAllTopics(t *testing.T) { } func TestRepositoriesService_ReplaceAllTopics_nilSlice(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -1039,7 +1039,7 @@ func TestRepositoriesService_ReplaceAllTopics_nilSlice(t *testing.T) { } func TestRepositoriesService_ReplaceAllTopics_emptySlice(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { From 0e33860e7e6fb0e9eb0201a7ddbb93d1da4a1815 Mon Sep 17 00:00:00 2001 From: Chris King Date: Thu, 16 Nov 2017 21:43:52 +0100 Subject: [PATCH 07/13] reverts all changes to contributing.md --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8489bc1bde1..68a23f00512 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ again. issue that you are planning to work on that bug or feature so that it can be assigned to you. - 1. Follow the normal process of [forking][] the project, and a new + 1. Follow the normal process of [forking][] the project, and setup a new branch to work in. It's important that each group of changes be done in separate branches in order to ensure that a pull request only includes the commits related to that bug or feature. @@ -55,7 +55,7 @@ again. [forking]: https://help.github.com/articles/fork-a-repo [golint]: https://github.com/golang/lint -[golint readme]: https://github.com/golang/lint/blob/master/README.md +[golint readme]: https://github.com/golang/lint/blob/master/README [gocov]: https://github.com/axw/gocov [gocov-html]: https://github.com/matm/gocov-html [well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html From 040a796650986b8336b877c1b1ce7d750f9890f2 Mon Sep 17 00:00:00 2001 From: Chris King Date: Thu, 16 Nov 2017 21:50:27 +0100 Subject: [PATCH 08/13] merges in changes to contributing.md from master --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 68a23f00512..8da635a6e59 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,7 +55,7 @@ again. [forking]: https://help.github.com/articles/fork-a-repo [golint]: https://github.com/golang/lint -[golint readme]: https://github.com/golang/lint/blob/master/README +[golint readme]: https://github.com/golang/lint/blob/master/README.md [gocov]: https://github.com/axw/gocov [gocov-html]: https://github.com/matm/gocov-html [well-formed commit messages]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html From eac6e9c7d748d87411e350cd706ebaae93da69df Mon Sep 17 00:00:00 2001 From: Chris King Date: Thu, 16 Nov 2017 21:56:14 +0100 Subject: [PATCH 09/13] re-includes removed comments --- github/github_test.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/github/github_test.go b/github/github_test.go index 0fe712d4665..3a6350dc337 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -32,7 +32,7 @@ const ( // configured to talk to that test server. Tests should register handlers on // mux which provide mock responses for the API method being tested. func setup() (string, *http.ServeMux, *Client, func()) { - // test server + // mux is the HTTP request multiplexer used with the test server. mux := http.NewServeMux() // We want to ensure that tests catch mistakes where the endpoint URL is @@ -50,9 +50,11 @@ func setup() (string, *http.ServeMux, *Client, func()) { http.Error(w, "Client.BaseURL path prefix is not preserved in the request URL.", http.StatusInternalServerError) }) + // server is a test HTTP server used to provide mock API responses. server := httptest.NewServer(apiHandler) - // github client configured to use test server + // client is the GitHub client being tested and is + // configured to use test server client := NewClient(nil) url, _ := url.Parse(server.URL + baseURLPath + "/") client.BaseURL = url From 6670f6adf661805cb9a4767787c95c0b85a6edad Mon Sep 17 00:00:00 2001 From: Chris King Date: Sat, 18 Nov 2017 09:56:31 +0100 Subject: [PATCH 10/13] names return values --- github/github_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/github/github_test.go b/github/github_test.go index 3a6350dc337..78f5067fc19 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -31,9 +31,9 @@ const ( // setup sets up a test HTTP server along with a github.Client that is // configured to talk to that test server. Tests should register handlers on // mux which provide mock responses for the API method being tested. -func setup() (string, *http.ServeMux, *Client, func()) { +func setup() (serverURL string, mux *http.ServeMux, client *Client, teardown func()) { // mux is the HTTP request multiplexer used with the test server. - mux := http.NewServeMux() + mux = http.NewServeMux() // We want to ensure that tests catch mistakes where the endpoint URL is // specified as absolute rather than relative. It only makes a difference @@ -55,7 +55,7 @@ func setup() (string, *http.ServeMux, *Client, func()) { // client is the GitHub client being tested and is // configured to use test server - client := NewClient(nil) + client = NewClient(nil) url, _ := url.Parse(server.URL + baseURLPath + "/") client.BaseURL = url client.UploadURL = url From 4663a349f51320931527af6a6b484949baa94e21 Mon Sep 17 00:00:00 2001 From: Chris King Date: Sat, 2 Dec 2017 11:30:41 +0100 Subject: [PATCH 11/13] fixes test from merge --- github/repos_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/repos_test.go b/github/repos_test.go index a1de49c44b1..e5ce5d87c8c 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -1061,7 +1061,7 @@ func TestRepositoriesService_ReplaceAllTopics_emptySlice(t *testing.T) { } func TestRepositoriesService_Transfer(t *testing.T) { - setup() + _, mux, client, teardown := setup() defer teardown() input := TransferRequest{NewOwner: "a", TeamID: []int{123}} From bb0ce6365df06bd583128250c7b39e6b0a15bc7c Mon Sep 17 00:00:00 2001 From: Chris King Date: Sat, 2 Dec 2017 11:40:50 +0100 Subject: [PATCH 12/13] alters return parameter ordering of setup func --- github/activity_events_test.go | 32 ++++----- github/activity_notifications_test.go | 18 ++--- github/activity_star_test.go | 22 +++--- github/activity_test.go | 2 +- github/activity_watching_test.go | 16 ++--- github/admin_stats_test.go | 2 +- github/admin_test.go | 4 +- github/apps_installation_test.go | 8 +-- github/apps_marketplace_test.go | 16 ++--- github/apps_test.go | 12 ++-- github/authorizations_test.go | 32 ++++----- github/gists_comments_test.go | 20 +++--- github/gists_test.go | 52 +++++++------- github/git_blobs_test.go | 8 +-- github/git_commits_test.go | 8 +-- github/git_refs_test.go | 20 +++--- github/git_tags_test.go | 4 +- github/git_trees_test.go | 10 +-- github/github_test.go | 30 ++++---- github/gitignore_test.go | 6 +- github/issues_assignees_test.go | 16 ++--- github/issues_comments_test.go | 22 +++--- github/issues_events_test.go | 6 +- github/issues_labels_test.go | 44 ++++++------ github/issues_milestones_test.go | 20 +++--- github/issues_test.go | 28 ++++---- github/issues_timeline_test.go | 2 +- github/licenses_test.go | 6 +- github/migrations_source_import_test.go | 16 ++--- github/migrations_test.go | 12 ++-- github/misc_test.go | 16 ++--- github/orgs_hooks_test.go | 18 ++--- github/orgs_members_test.go | 40 +++++------ github/orgs_outside_collaborators_test.go | 4 +- github/orgs_projects_test.go | 4 +- github/orgs_teams_test.go | 66 ++++++++--------- github/orgs_test.go | 18 ++--- github/orgs_users_blocking_test.go | 8 +-- github/projects_test.go | 30 ++++---- github/pulls_comments_test.go | 22 +++--- github/pulls_reviewers_test.go | 8 +-- github/pulls_reviews_test.go | 30 ++++---- github/pulls_test.go | 36 +++++----- github/reactions_test.go | 18 ++--- github/repos_collaborators_test.go | 22 +++--- github/repos_comments_test.go | 24 +++---- github/repos_commits_test.go | 14 ++-- github/repos_community_health_test.go | 2 +- github/repos_contents_test.go | 28 ++++---- github/repos_deployments_test.go | 12 ++-- github/repos_forks_test.go | 8 +-- github/repos_hooks_test.go | 26 +++---- github/repos_invitations_test.go | 6 +- github/repos_keys_test.go | 20 +++--- github/repos_merging_test.go | 2 +- github/repos_pages_test.go | 12 ++-- github/repos_projects_test.go | 4 +- github/repos_releases_test.go | 30 ++++---- github/repos_stats_test.go | 10 +-- github/repos_statuses_test.go | 10 +-- github/repos_test.go | 86 +++++++++++------------ github/repos_traffic_test.go | 8 +-- github/search_test.go | 14 ++-- github/users_administration_test.go | 8 +-- github/users_blocking_test.go | 8 +-- github/users_emails_test.go | 6 +- github/users_followers_test.go | 30 ++++---- github/users_gpg_keys_test.go | 12 ++-- github/users_keys_test.go | 12 ++-- github/users_test.go | 20 +++--- 70 files changed, 623 insertions(+), 623 deletions(-) diff --git a/github/activity_events_test.go b/github/activity_events_test.go index 923454839d5..dc92a98394c 100644 --- a/github/activity_events_test.go +++ b/github/activity_events_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListEvents(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/events", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestActivityService_ListEvents(t *testing.T) { } func TestActivityService_ListRepositoryEvents(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/events", func(w http.ResponseWriter, r *http.Request) { @@ -63,7 +63,7 @@ func TestActivityService_ListRepositoryEvents(t *testing.T) { } func TestActivityService_ListRepositoryEvents_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Activity.ListRepositoryEvents(context.Background(), "%", "%", nil) @@ -71,7 +71,7 @@ func TestActivityService_ListRepositoryEvents_invalidOwner(t *testing.T) { } func TestActivityService_ListIssueEventsForRepository(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events", func(w http.ResponseWriter, r *http.Request) { @@ -95,7 +95,7 @@ func TestActivityService_ListIssueEventsForRepository(t *testing.T) { } func TestActivityService_ListIssueEventsForRepository_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Activity.ListIssueEventsForRepository(context.Background(), "%", "%", nil) @@ -103,7 +103,7 @@ func TestActivityService_ListIssueEventsForRepository_invalidOwner(t *testing.T) } func TestActivityService_ListEventsForRepoNetwork(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/networks/o/r/events", func(w http.ResponseWriter, r *http.Request) { @@ -127,7 +127,7 @@ func TestActivityService_ListEventsForRepoNetwork(t *testing.T) { } func TestActivityService_ListEventsForRepoNetwork_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Activity.ListEventsForRepoNetwork(context.Background(), "%", "%", nil) @@ -135,7 +135,7 @@ func TestActivityService_ListEventsForRepoNetwork_invalidOwner(t *testing.T) { } func TestActivityService_ListEventsForOrganization(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/events", func(w http.ResponseWriter, r *http.Request) { @@ -159,7 +159,7 @@ func TestActivityService_ListEventsForOrganization(t *testing.T) { } func TestActivityService_ListEventsForOrganization_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Activity.ListEventsForOrganization(context.Background(), "%", nil) @@ -167,7 +167,7 @@ func TestActivityService_ListEventsForOrganization_invalidOrg(t *testing.T) { } func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events", func(w http.ResponseWriter, r *http.Request) { @@ -191,7 +191,7 @@ func TestActivityService_ListEventsPerformedByUser_all(t *testing.T) { } func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events/public", func(w http.ResponseWriter, r *http.Request) { @@ -211,7 +211,7 @@ func TestActivityService_ListEventsPerformedByUser_publicOnly(t *testing.T) { } func TestActivityService_ListEventsPerformedByUser_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Activity.ListEventsPerformedByUser(context.Background(), "%", false, nil) @@ -219,7 +219,7 @@ func TestActivityService_ListEventsPerformedByUser_invalidUser(t *testing.T) { } func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/received_events", func(w http.ResponseWriter, r *http.Request) { @@ -243,7 +243,7 @@ func TestActivityService_ListEventsReceivedByUser_all(t *testing.T) { } func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/received_events/public", func(w http.ResponseWriter, r *http.Request) { @@ -263,7 +263,7 @@ func TestActivityService_ListEventsReceivedByUser_publicOnly(t *testing.T) { } func TestActivityService_ListEventsReceivedByUser_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Activity.ListEventsReceivedByUser(context.Background(), "%", false, nil) @@ -271,7 +271,7 @@ func TestActivityService_ListEventsReceivedByUser_invalidUser(t *testing.T) { } func TestActivityService_ListUserEventsForOrganization(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/events/orgs/o", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_notifications_test.go b/github/activity_notifications_test.go index 47d230369b4..292e3e2433c 100644 --- a/github/activity_notifications_test.go +++ b/github/activity_notifications_test.go @@ -16,7 +16,7 @@ import ( ) func TestActivityService_ListNotification(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestActivityService_ListNotification(t *testing.T) { } func TestActivityService_ListRepositoryNotification(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestActivityService_ListRepositoryNotification(t *testing.T) { } func TestActivityService_MarkNotificationsRead(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -87,7 +87,7 @@ func TestActivityService_MarkNotificationsRead(t *testing.T) { } func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/notifications", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestActivityService_MarkRepositoryNotificationsRead(t *testing.T) { } func TestActivityService_GetThread(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestActivityService_GetThread(t *testing.T) { } func TestActivityService_MarkThreadRead(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1", func(w http.ResponseWriter, r *http.Request) { @@ -140,7 +140,7 @@ func TestActivityService_MarkThreadRead(t *testing.T) { } func TestActivityService_GetThreadSubscription(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -160,7 +160,7 @@ func TestActivityService_GetThreadSubscription(t *testing.T) { } func TestActivityService_SetThreadSubscription(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Subscription{Subscribed: Bool(true)} @@ -189,7 +189,7 @@ func TestActivityService_SetThreadSubscription(t *testing.T) { } func TestActivityService_DeleteThreadSubscription(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/notifications/threads/1/subscription", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_star_test.go b/github/activity_star_test.go index 952e8bc8552..16ae695b3f5 100644 --- a/github/activity_star_test.go +++ b/github/activity_star_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListStargazers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stargazers", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestActivityService_ListStargazers(t *testing.T) { } func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/starred", func(w http.ResponseWriter, r *http.Request) { @@ -61,7 +61,7 @@ func TestActivityService_ListStarred_authenticatedUser(t *testing.T) { } func TestActivityService_ListStarred_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/starred", func(w http.ResponseWriter, r *http.Request) { @@ -88,7 +88,7 @@ func TestActivityService_ListStarred_specifiedUser(t *testing.T) { } func TestActivityService_ListStarred_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Activity.ListStarred(context.Background(), "%", nil) @@ -96,7 +96,7 @@ func TestActivityService_ListStarred_invalidUser(t *testing.T) { } func TestActivityService_IsStarred_hasStar(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -114,7 +114,7 @@ func TestActivityService_IsStarred_hasStar(t *testing.T) { } func TestActivityService_IsStarred_noStar(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -132,7 +132,7 @@ func TestActivityService_IsStarred_noStar(t *testing.T) { } func TestActivityService_IsStarred_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Activity.IsStarred(context.Background(), "%", "%") @@ -140,7 +140,7 @@ func TestActivityService_IsStarred_invalidID(t *testing.T) { } func TestActivityService_Star(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -154,7 +154,7 @@ func TestActivityService_Star(t *testing.T) { } func TestActivityService_Star_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Activity.Star(context.Background(), "%", "%") @@ -162,7 +162,7 @@ func TestActivityService_Star_invalidID(t *testing.T) { } func TestActivityService_Unstar(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/starred/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -176,7 +176,7 @@ func TestActivityService_Unstar(t *testing.T) { } func TestActivityService_Unstar_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Activity.Unstar(context.Background(), "%", "%") diff --git a/github/activity_test.go b/github/activity_test.go index a47b074cfc4..92b42d3a727 100644 --- a/github/activity_test.go +++ b/github/activity_test.go @@ -13,7 +13,7 @@ import ( ) func TestActivityService_List(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/feeds", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/activity_watching_test.go b/github/activity_watching_test.go index c353f8ac896..d3d0d9697de 100644 --- a/github/activity_watching_test.go +++ b/github/activity_watching_test.go @@ -15,7 +15,7 @@ import ( ) func TestActivityService_ListWatchers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscribers", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestActivityService_ListWatchers(t *testing.T) { } func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/subscriptions", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestActivityService_ListWatched_authenticatedUser(t *testing.T) { } func TestActivityService_ListWatched_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/subscriptions", func(w http.ResponseWriter, r *http.Request) { @@ -85,7 +85,7 @@ func TestActivityService_ListWatched_specifiedUser(t *testing.T) { } func TestActivityService_GetRepositorySubscription_true(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestActivityService_GetRepositorySubscription_true(t *testing.T) { } func TestActivityService_GetRepositorySubscription_false(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestActivityService_GetRepositorySubscription_false(t *testing.T) { } func TestActivityService_GetRepositorySubscription_error(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { @@ -140,7 +140,7 @@ func TestActivityService_GetRepositorySubscription_error(t *testing.T) { } func TestActivityService_SetRepositorySubscription(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Subscription{Subscribed: Bool(true)} @@ -169,7 +169,7 @@ func TestActivityService_SetRepositorySubscription(t *testing.T) { } func TestActivityService_DeleteRepositorySubscription(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/subscription", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/admin_stats_test.go b/github/admin_stats_test.go index e5ec5db2b9b..9433adc37b0 100644 --- a/github/admin_stats_test.go +++ b/github/admin_stats_test.go @@ -9,7 +9,7 @@ import ( ) func TestAdminService_GetAdminStats(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/enterprise/stats/all", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/admin_test.go b/github/admin_test.go index 10f3bec26f1..0e693a736a0 100644 --- a/github/admin_test.go +++ b/github/admin_test.go @@ -15,7 +15,7 @@ import ( ) func TestAdminService_UpdateUserLDAPMapping(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &UserLDAPMapping{ @@ -48,7 +48,7 @@ func TestAdminService_UpdateUserLDAPMapping(t *testing.T) { } func TestAdminService_UpdateTeamLDAPMapping(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &TeamLDAPMapping{ diff --git a/github/apps_installation_test.go b/github/apps_installation_test.go index 6ccaed3ceb0..68d47a76751 100644 --- a/github/apps_installation_test.go +++ b/github/apps_installation_test.go @@ -14,7 +14,7 @@ import ( ) func TestAppsService_ListRepos(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/installation/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestAppsService_ListRepos(t *testing.T) { } func TestAppsService_ListUserRepos(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/installations/1/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func TestAppsService_ListUserRepos(t *testing.T) { } func TestAppsService_AddRepository(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/apps/installations/1/repositories/1", func(w http.ResponseWriter, r *http.Request) { @@ -85,7 +85,7 @@ func TestAppsService_AddRepository(t *testing.T) { } func TestAppsService_RemoveRepository(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/apps/installations/1/repositories/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/apps_marketplace_test.go b/github/apps_marketplace_test.go index 13c91613f3e..59c6b318222 100644 --- a/github/apps_marketplace_test.go +++ b/github/apps_marketplace_test.go @@ -14,7 +14,7 @@ import ( ) func TestMarketplaceService_ListPlans(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/plans", func(w http.ResponseWriter, r *http.Request) { @@ -41,7 +41,7 @@ func TestMarketplaceService_ListPlans(t *testing.T) { } func TestMarketplaceService_Stubbed_ListPlans(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/stubbed/plans", func(w http.ResponseWriter, r *http.Request) { @@ -64,7 +64,7 @@ func TestMarketplaceService_Stubbed_ListPlans(t *testing.T) { } func TestMarketplaceService_ListPlanAccountsForPlan(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/plans/1/accounts", func(w http.ResponseWriter, r *http.Request) { @@ -87,7 +87,7 @@ func TestMarketplaceService_ListPlanAccountsForPlan(t *testing.T) { } func TestMarketplaceService_Stubbed_ListPlanAccountsForPlan(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/stubbed/plans/1/accounts", func(w http.ResponseWriter, r *http.Request) { @@ -110,7 +110,7 @@ func TestMarketplaceService_Stubbed_ListPlanAccountsForPlan(t *testing.T) { } func TestMarketplaceService_ListPlanAccountsForAccount(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/accounts/1", func(w http.ResponseWriter, r *http.Request) { @@ -133,7 +133,7 @@ func TestMarketplaceService_ListPlanAccountsForAccount(t *testing.T) { } func TestMarketplaceService_Stubbed_ListPlanAccountsForAccount(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/marketplace_listing/stubbed/accounts/1", func(w http.ResponseWriter, r *http.Request) { @@ -156,7 +156,7 @@ func TestMarketplaceService_Stubbed_ListPlanAccountsForAccount(t *testing.T) { } func TestMarketplaceService_ListMarketplacePurchasesForUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/marketplace_purchases", func(w http.ResponseWriter, r *http.Request) { @@ -179,7 +179,7 @@ func TestMarketplaceService_ListMarketplacePurchasesForUser(t *testing.T) { } func TestMarketplaceService_Stubbed_ListMarketplacePurchasesForUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/marketplace_purchases/stubbed", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/apps_test.go b/github/apps_test.go index f331cf1c4aa..2a080964792 100644 --- a/github/apps_test.go +++ b/github/apps_test.go @@ -14,7 +14,7 @@ import ( ) func TestAppsService_Get_authenticatedApp(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/app", func(w http.ResponseWriter, r *http.Request) { @@ -35,7 +35,7 @@ func TestAppsService_Get_authenticatedApp(t *testing.T) { } func TestAppsService_Get_specifiedApp(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/apps/a", func(w http.ResponseWriter, r *http.Request) { @@ -56,7 +56,7 @@ func TestAppsService_Get_specifiedApp(t *testing.T) { } func TestAppsService_ListInstallations(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/app/installations", func(w http.ResponseWriter, r *http.Request) { @@ -82,7 +82,7 @@ func TestAppsService_ListInstallations(t *testing.T) { } func TestAppsService_GetInstallation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/app/installations/1", func(w http.ResponseWriter, r *http.Request) { @@ -103,7 +103,7 @@ func TestAppsService_GetInstallation(t *testing.T) { } func TestAppsService_ListUserInstallations(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/installations", func(w http.ResponseWriter, r *http.Request) { @@ -129,7 +129,7 @@ func TestAppsService_ListUserInstallations(t *testing.T) { } func TestAppsService_CreateInstallationToken(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/installations/1/access_tokens", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/authorizations_test.go b/github/authorizations_test.go index 58c9738fd12..fc39c199953 100644 --- a/github/authorizations_test.go +++ b/github/authorizations_test.go @@ -15,7 +15,7 @@ import ( ) func TestAuthorizationsService_List(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/authorizations", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestAuthorizationsService_List(t *testing.T) { } func TestAuthorizationsService_Get(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestAuthorizationsService_Get(t *testing.T) { } func TestAuthorizationsService_Create(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -88,7 +88,7 @@ func TestAuthorizationsService_Create(t *testing.T) { } func TestAuthorizationsService_GetOrCreateForApp(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -119,7 +119,7 @@ func TestAuthorizationsService_GetOrCreateForApp(t *testing.T) { } func TestAuthorizationsService_GetOrCreateForApp_Fingerprint(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &AuthorizationRequest{ @@ -151,7 +151,7 @@ func TestAuthorizationsService_GetOrCreateForApp_Fingerprint(t *testing.T) { } func TestAuthorizationsService_Edit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &AuthorizationUpdateRequest{ @@ -182,7 +182,7 @@ func TestAuthorizationsService_Edit(t *testing.T) { } func TestAuthorizationsService_Delete(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/authorizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -197,7 +197,7 @@ func TestAuthorizationsService_Delete(t *testing.T) { } func TestAuthorizationsService_Check(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -217,7 +217,7 @@ func TestAuthorizationsService_Check(t *testing.T) { } func TestAuthorizationsService_Reset(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -237,7 +237,7 @@ func TestAuthorizationsService_Reset(t *testing.T) { } func TestAuthorizationsService_Revoke(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/applications/id/tokens/t", func(w http.ResponseWriter, r *http.Request) { @@ -252,7 +252,7 @@ func TestAuthorizationsService_Revoke(t *testing.T) { } func TestListGrants(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) { @@ -272,7 +272,7 @@ func TestListGrants(t *testing.T) { } func TestListGrants_withOptions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants", func(w http.ResponseWriter, r *http.Request) { @@ -290,7 +290,7 @@ func TestListGrants_withOptions(t *testing.T) { } func TestGetGrant(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) { @@ -310,7 +310,7 @@ func TestGetGrant(t *testing.T) { } func TestDeleteGrant(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/applications/grants/1", func(w http.ResponseWriter, r *http.Request) { @@ -324,7 +324,7 @@ func TestDeleteGrant(t *testing.T) { } func TestAuthorizationsService_CreateImpersonation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) { @@ -345,7 +345,7 @@ func TestAuthorizationsService_CreateImpersonation(t *testing.T) { } func TestAuthorizationsService_DeleteImpersonation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/admin/users/u/authorizations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/gists_comments_test.go b/github/gists_comments_test.go index 7952e110d34..5b8026f784e 100644 --- a/github/gists_comments_test.go +++ b/github/gists_comments_test.go @@ -15,7 +15,7 @@ import ( ) func TestGistsService_ListComments(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestGistsService_ListComments(t *testing.T) { } func TestGistsService_ListComments_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.ListComments(context.Background(), "%", nil) @@ -45,7 +45,7 @@ func TestGistsService_ListComments_invalidID(t *testing.T) { } func TestGistsService_GetComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func TestGistsService_GetComment(t *testing.T) { } func TestGistsService_GetComment_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.GetComment(context.Background(), "%", 1) @@ -73,7 +73,7 @@ func TestGistsService_GetComment_invalidID(t *testing.T) { } func TestGistsService_CreateComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &GistComment{ID: Int(1), Body: String("b")} @@ -102,7 +102,7 @@ func TestGistsService_CreateComment(t *testing.T) { } func TestGistsService_CreateComment_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.CreateComment(context.Background(), "%", nil) @@ -110,7 +110,7 @@ func TestGistsService_CreateComment_invalidID(t *testing.T) { } func TestGistsService_EditComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &GistComment{ID: Int(1), Body: String("b")} @@ -139,7 +139,7 @@ func TestGistsService_EditComment(t *testing.T) { } func TestGistsService_EditComment_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.EditComment(context.Background(), "%", 1, nil) @@ -147,7 +147,7 @@ func TestGistsService_EditComment_invalidID(t *testing.T) { } func TestGistsService_DeleteComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/comments/2", func(w http.ResponseWriter, r *http.Request) { @@ -161,7 +161,7 @@ func TestGistsService_DeleteComment(t *testing.T) { } func TestGistsService_DeleteComment_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Gists.DeleteComment(context.Background(), "%", 1) diff --git a/github/gists_test.go b/github/gists_test.go index 4c76d436e1b..45ff9954b6a 100644 --- a/github/gists_test.go +++ b/github/gists_test.go @@ -16,7 +16,7 @@ import ( ) func TestGistsService_List_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -42,7 +42,7 @@ func TestGistsService_List_specifiedUser(t *testing.T) { } func TestGistsService_List_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestGistsService_List_authenticatedUser(t *testing.T) { } func TestGistsService_List_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.List(context.Background(), "%", nil) @@ -70,7 +70,7 @@ func TestGistsService_List_invalidUser(t *testing.T) { } func TestGistsService_ListAll(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -96,7 +96,7 @@ func TestGistsService_ListAll(t *testing.T) { } func TestGistsService_ListStarred(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() since := "2013-01-01T00:00:00Z" @@ -122,7 +122,7 @@ func TestGistsService_ListStarred(t *testing.T) { } func TestGistsService_Get(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) { @@ -142,7 +142,7 @@ func TestGistsService_Get(t *testing.T) { } func TestGistsService_Get_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.Get(context.Background(), "%") @@ -150,7 +150,7 @@ func TestGistsService_Get_invalidID(t *testing.T) { } func TestGistsService_GetRevision(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/s", func(w http.ResponseWriter, r *http.Request) { @@ -170,7 +170,7 @@ func TestGistsService_GetRevision(t *testing.T) { } func TestGistsService_GetRevision_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.GetRevision(context.Background(), "%", "%") @@ -178,7 +178,7 @@ func TestGistsService_GetRevision_invalidID(t *testing.T) { } func TestGistsService_Create(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Gist{ @@ -231,7 +231,7 @@ func TestGistsService_Create(t *testing.T) { } func TestGistsService_Edit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Gist{ @@ -287,7 +287,7 @@ func TestGistsService_Edit(t *testing.T) { } func TestGistsService_Edit_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.Edit(context.Background(), "%", nil) @@ -295,7 +295,7 @@ func TestGistsService_Edit_invalidID(t *testing.T) { } func TestGistsService_ListCommits(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -342,7 +342,7 @@ func TestGistsService_ListCommits(t *testing.T) { } func TestGistsService_ListCommits_withOptions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -360,7 +360,7 @@ func TestGistsService_ListCommits_withOptions(t *testing.T) { } func TestGistsService_Delete(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) { @@ -374,7 +374,7 @@ func TestGistsService_Delete(t *testing.T) { } func TestGistsService_Delete_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Gists.Delete(context.Background(), "%") @@ -382,7 +382,7 @@ func TestGistsService_Delete_invalidID(t *testing.T) { } func TestGistsService_Star(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -396,7 +396,7 @@ func TestGistsService_Star(t *testing.T) { } func TestGistsService_Star_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Gists.Star(context.Background(), "%") @@ -404,7 +404,7 @@ func TestGistsService_Star_invalidID(t *testing.T) { } func TestGistsService_Unstar(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -418,7 +418,7 @@ func TestGistsService_Unstar(t *testing.T) { } func TestGistsService_Unstar_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Gists.Unstar(context.Background(), "%") @@ -426,7 +426,7 @@ func TestGistsService_Unstar_invalidID(t *testing.T) { } func TestGistsService_IsStarred_hasStar(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -444,7 +444,7 @@ func TestGistsService_IsStarred_hasStar(t *testing.T) { } func TestGistsService_IsStarred_noStar(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/star", func(w http.ResponseWriter, r *http.Request) { @@ -462,7 +462,7 @@ func TestGistsService_IsStarred_noStar(t *testing.T) { } func TestGistsService_IsStarred_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.IsStarred(context.Background(), "%") @@ -470,7 +470,7 @@ func TestGistsService_IsStarred_invalidID(t *testing.T) { } func TestGistsService_Fork(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) { @@ -490,7 +490,7 @@ func TestGistsService_Fork(t *testing.T) { } func TestGistsService_ListForks(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gists/1/forks", func(w http.ResponseWriter, r *http.Request) { @@ -526,7 +526,7 @@ func TestGistsService_ListForks(t *testing.T) { } func TestGistsService_Fork_invalidID(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gists.Fork(context.Background(), "%") diff --git a/github/git_blobs_test.go b/github/git_blobs_test.go index a199021fc78..0bf87a33dda 100644 --- a/github/git_blobs_test.go +++ b/github/git_blobs_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetBlob(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/blobs/s", func(w http.ResponseWriter, r *http.Request) { @@ -44,7 +44,7 @@ func TestGitService_GetBlob(t *testing.T) { } func TestGitService_GetBlob_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Git.GetBlob(context.Background(), "%", "%", "%") @@ -52,7 +52,7 @@ func TestGitService_GetBlob_invalidOwner(t *testing.T) { } func TestGitService_CreateBlob(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Blob{ @@ -96,7 +96,7 @@ func TestGitService_CreateBlob(t *testing.T) { } func TestGitService_CreateBlob_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Git.CreateBlob(context.Background(), "%", "%", &Blob{}) diff --git a/github/git_commits_test.go b/github/git_commits_test.go index ecf45e4f871..ff8827f9035 100644 --- a/github/git_commits_test.go +++ b/github/git_commits_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetCommit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/commits/s", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestGitService_GetCommit(t *testing.T) { } func TestGitService_GetCommit_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Git.GetCommit(context.Background(), "%", "%", "%") @@ -44,7 +44,7 @@ func TestGitService_GetCommit_invalidOwner(t *testing.T) { } func TestGitService_CreateCommit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Commit{ @@ -82,7 +82,7 @@ func TestGitService_CreateCommit(t *testing.T) { } func TestGitService_CreateCommit_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Git.CreateCommit(context.Background(), "%", "%", &Commit{}) diff --git a/github/git_refs_test.go b/github/git_refs_test.go index 0e8efce5545..3cae3c085fd 100644 --- a/github/git_refs_test.go +++ b/github/git_refs_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetRef_singleRef(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestGitService_GetRef_singleRef(t *testing.T) { } func TestGitService_GetRef_multipleRefs(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -95,7 +95,7 @@ func TestGitService_GetRef_multipleRefs(t *testing.T) { } func TestGitService_GetRefs_singleRef(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -138,7 +138,7 @@ func TestGitService_GetRefs_singleRef(t *testing.T) { } func TestGitService_GetRefs_multipleRefs(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -188,7 +188,7 @@ func TestGitService_GetRefs_multipleRefs(t *testing.T) { // TestGitService_GetRefs_noRefs tests for behaviour resulting from an unexpected GH response. This should never actually happen. func TestGitService_GetRefs_noRefs(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { @@ -205,7 +205,7 @@ func TestGitService_GetRefs_noRefs(t *testing.T) { } func TestGitService_ListRefs(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs", func(w http.ResponseWriter, r *http.Request) { @@ -264,7 +264,7 @@ func TestGitService_ListRefs(t *testing.T) { } func TestGitService_ListRefs_options(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/t", func(w http.ResponseWriter, r *http.Request) { @@ -286,7 +286,7 @@ func TestGitService_ListRefs_options(t *testing.T) { } func TestGitService_CreateRef(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() args := &createRefRequest{ @@ -350,7 +350,7 @@ func TestGitService_CreateRef(t *testing.T) { } func TestGitService_UpdateRef(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() args := &updateRefRequest{ @@ -410,7 +410,7 @@ func TestGitService_UpdateRef(t *testing.T) { } func TestGitService_DeleteRef(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/git_tags_test.go b/github/git_tags_test.go index 5b591951404..8a676a3b453 100644 --- a/github/git_tags_test.go +++ b/github/git_tags_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetTag(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/tags/s", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestGitService_GetTag(t *testing.T) { } func TestGitService_CreateTag(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &createTagRequest{Tag: String("t"), Object: String("s")} diff --git a/github/git_trees_test.go b/github/git_trees_test.go index 9f733e63a8c..176cbac079d 100644 --- a/github/git_trees_test.go +++ b/github/git_trees_test.go @@ -15,7 +15,7 @@ import ( ) func TestGitService_GetTree(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/git/trees/s", func(w http.ResponseWriter, r *http.Request) { @@ -47,7 +47,7 @@ func TestGitService_GetTree(t *testing.T) { } func TestGitService_GetTree_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Git.GetTree(context.Background(), "%", "%", "%", false) @@ -55,7 +55,7 @@ func TestGitService_GetTree_invalidOwner(t *testing.T) { } func TestGitService_CreateTree(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := []TreeEntry{ @@ -121,7 +121,7 @@ func TestGitService_CreateTree(t *testing.T) { } func TestGitService_CreateTree_Content(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := []TreeEntry{ @@ -189,7 +189,7 @@ func TestGitService_CreateTree_Content(t *testing.T) { } func TestGitService_CreateTree_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Git.CreateTree(context.Background(), "%", "%", "", nil) diff --git a/github/github_test.go b/github/github_test.go index 78f5067fc19..a010055eeb1 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -31,7 +31,7 @@ const ( // setup sets up a test HTTP server along with a github.Client that is // configured to talk to that test server. Tests should register handlers on // mux which provide mock responses for the API method being tested. -func setup() (serverURL string, mux *http.ServeMux, client *Client, teardown func()) { +func setup() (client *Client, mux *http.ServeMux, serverURL string, teardown func()) { // mux is the HTTP request multiplexer used with the test server. mux = http.NewServeMux() @@ -60,7 +60,7 @@ func setup() (serverURL string, mux *http.ServeMux, client *Client, teardown fun client.BaseURL = url client.UploadURL = url - return server.URL, mux, client, server.Close + return client, mux, server.URL, server.Close } // openTestFile creates a new file with the given name and content for testing. @@ -405,7 +405,7 @@ func TestResponse_populatePageValues_invalid(t *testing.T) { } func TestDo(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() type foo struct { @@ -430,7 +430,7 @@ func TestDo(t *testing.T) { } func TestDo_httpError(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -452,7 +452,7 @@ func TestDo_httpError(t *testing.T) { // function. A redirect loop is pretty unlikely to occur within the GitHub // API, but does allow us to exercise the right code path. func TestDo_redirectLoop(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -493,7 +493,7 @@ func TestDo_sanitizeURL(t *testing.T) { } func TestDo_rateLimit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -521,7 +521,7 @@ func TestDo_rateLimit(t *testing.T) { // ensure rate limit is still parsed, even for error responses func TestDo_rateLimit_errorResponse(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -553,7 +553,7 @@ func TestDo_rateLimit_errorResponse(t *testing.T) { // Ensure *RateLimitError is returned when API rate limit is exceeded. func TestDo_rateLimit_rateLimitError(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -592,7 +592,7 @@ func TestDo_rateLimit_rateLimitError(t *testing.T) { // Ensure a network call is not made when it's known that API rate limit is still exceeded. func TestDo_rateLimit_noNetworkCall(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() reset := time.Now().UTC().Add(time.Minute).Round(time.Second) // Rate reset is a minute from now, with 1 second precision. @@ -647,7 +647,7 @@ func TestDo_rateLimit_noNetworkCall(t *testing.T) { // Ensure *AbuseRateLimitError is returned when the response indicates that // the client has triggered an abuse detection mechanism. func TestDo_rateLimit_abuseRateLimitError(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -678,7 +678,7 @@ func TestDo_rateLimit_abuseRateLimitError(t *testing.T) { // Ensure *AbuseRateLimitError.RetryAfter is parsed correctly. func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -710,7 +710,7 @@ func TestDo_rateLimit_abuseRateLimitError_retryAfter(t *testing.T) { } func TestDo_noContent(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -849,7 +849,7 @@ func TestError_Error(t *testing.T) { } func TestRateLimits(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/rate_limit", func(w http.ResponseWriter, r *http.Request) { @@ -892,7 +892,7 @@ func TestRateLimits(t *testing.T) { } func TestUnauthenticatedRateLimitedTransport(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { @@ -958,7 +958,7 @@ func TestUnauthenticatedRateLimitedTransport_transport(t *testing.T) { } func TestBasicAuthTransport(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() username, password, otp := "u", "p", "123456" diff --git a/github/gitignore_test.go b/github/gitignore_test.go index aac37bd0a34..cdb82237ce7 100644 --- a/github/gitignore_test.go +++ b/github/gitignore_test.go @@ -14,7 +14,7 @@ import ( ) func TestGitignoresService_List(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gitignore/templates", func(w http.ResponseWriter, r *http.Request) { @@ -34,7 +34,7 @@ func TestGitignoresService_List(t *testing.T) { } func TestGitignoresService_Get(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/gitignore/templates/name", func(w http.ResponseWriter, r *http.Request) { @@ -54,7 +54,7 @@ func TestGitignoresService_Get(t *testing.T) { } func TestGitignoresService_Get_invalidTemplate(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Gitignores.Get(context.Background(), "%") diff --git a/github/issues_assignees_test.go b/github/issues_assignees_test.go index ddc7ddaa4f9..b73cb60dee0 100644 --- a/github/issues_assignees_test.go +++ b/github/issues_assignees_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListAssignees(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestIssuesService_ListAssignees(t *testing.T) { } func TestIssuesService_ListAssignees_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ListAssignees(context.Background(), "%", "r", nil) @@ -45,7 +45,7 @@ func TestIssuesService_ListAssignees_invalidOwner(t *testing.T) { } func TestIssuesService_IsAssignee_true(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestIssuesService_IsAssignee_true(t *testing.T) { } func TestIssuesService_IsAssignee_false(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -80,7 +80,7 @@ func TestIssuesService_IsAssignee_false(t *testing.T) { } func TestIssuesService_IsAssignee_error(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/assignees/u", func(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func TestIssuesService_IsAssignee_error(t *testing.T) { } func TestIssuesService_IsAssignee_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.IsAssignee(context.Background(), "%", "r", "u") @@ -106,7 +106,7 @@ func TestIssuesService_IsAssignee_invalidOwner(t *testing.T) { } func TestIssuesService_AddAssignees(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) { @@ -135,7 +135,7 @@ func TestIssuesService_AddAssignees(t *testing.T) { } func TestIssuesService_RemoveAssignees(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/assignees", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_comments_test.go b/github/issues_comments_test.go index 573bd53861c..6ed42240dca 100644 --- a/github/issues_comments_test.go +++ b/github/issues_comments_test.go @@ -16,7 +16,7 @@ import ( ) func TestIssuesService_ListComments_allIssues(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestIssuesService_ListComments_allIssues(t *testing.T) { } func TestIssuesService_ListComments_specificIssue(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestIssuesService_ListComments_specificIssue(t *testing.T) { } func TestIssuesService_ListComments_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ListComments(context.Background(), "%", "r", 1, nil) @@ -78,7 +78,7 @@ func TestIssuesService_ListComments_invalidOwner(t *testing.T) { } func TestIssuesService_GetComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -99,7 +99,7 @@ func TestIssuesService_GetComment(t *testing.T) { } func TestIssuesService_GetComment_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.GetComment(context.Background(), "%", "r", 1) @@ -107,7 +107,7 @@ func TestIssuesService_GetComment_invalidOrg(t *testing.T) { } func TestIssuesService_CreateComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &IssueComment{Body: String("b")} @@ -136,7 +136,7 @@ func TestIssuesService_CreateComment(t *testing.T) { } func TestIssuesService_CreateComment_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.CreateComment(context.Background(), "%", "r", 1, nil) @@ -144,7 +144,7 @@ func TestIssuesService_CreateComment_invalidOrg(t *testing.T) { } func TestIssuesService_EditComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &IssueComment{Body: String("b")} @@ -173,7 +173,7 @@ func TestIssuesService_EditComment(t *testing.T) { } func TestIssuesService_EditComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.EditComment(context.Background(), "%", "r", 1, nil) @@ -181,7 +181,7 @@ func TestIssuesService_EditComment_invalidOwner(t *testing.T) { } func TestIssuesService_DeleteComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -195,7 +195,7 @@ func TestIssuesService_DeleteComment(t *testing.T) { } func TestIssuesService_DeleteComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Issues.DeleteComment(context.Background(), "%", "r", 1) diff --git a/github/issues_events_test.go b/github/issues_events_test.go index 8dd82002a12..c0133dd45ae 100644 --- a/github/issues_events_test.go +++ b/github/issues_events_test.go @@ -14,7 +14,7 @@ import ( ) func TestIssuesService_ListIssueEvents(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/events", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestIssuesService_ListIssueEvents(t *testing.T) { } func TestIssuesService_ListRepositoryEvents(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events", func(w http.ResponseWriter, r *http.Request) { @@ -64,7 +64,7 @@ func TestIssuesService_ListRepositoryEvents(t *testing.T) { } func TestIssuesService_GetEvent(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/events/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_labels_test.go b/github/issues_labels_test.go index 0487263acc2..56c20e552fd 100644 --- a/github/issues_labels_test.go +++ b/github/issues_labels_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListLabels(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestIssuesService_ListLabels(t *testing.T) { } func TestIssuesService_ListLabels_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ListLabels(context.Background(), "%", "%", nil) @@ -45,7 +45,7 @@ func TestIssuesService_ListLabels_invalidOwner(t *testing.T) { } func TestIssuesService_GetLabel(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func TestIssuesService_GetLabel(t *testing.T) { } func TestIssuesService_GetLabel_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.GetLabel(context.Background(), "%", "%", "%") @@ -73,7 +73,7 @@ func TestIssuesService_GetLabel_invalidOwner(t *testing.T) { } func TestIssuesService_CreateLabel(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Label{Name: String("n")} @@ -102,7 +102,7 @@ func TestIssuesService_CreateLabel(t *testing.T) { } func TestIssuesService_CreateLabel_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.CreateLabel(context.Background(), "%", "%", nil) @@ -110,7 +110,7 @@ func TestIssuesService_CreateLabel_invalidOwner(t *testing.T) { } func TestIssuesService_EditLabel(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Label{Name: String("z")} @@ -139,7 +139,7 @@ func TestIssuesService_EditLabel(t *testing.T) { } func TestIssuesService_EditLabel_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.EditLabel(context.Background(), "%", "%", "%", nil) @@ -147,7 +147,7 @@ func TestIssuesService_EditLabel_invalidOwner(t *testing.T) { } func TestIssuesService_DeleteLabel(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/labels/n", func(w http.ResponseWriter, r *http.Request) { @@ -161,7 +161,7 @@ func TestIssuesService_DeleteLabel(t *testing.T) { } func TestIssuesService_DeleteLabel_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Issues.DeleteLabel(context.Background(), "%", "%", "%") @@ -169,7 +169,7 @@ func TestIssuesService_DeleteLabel_invalidOwner(t *testing.T) { } func TestIssuesService_ListLabelsByIssue(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -194,7 +194,7 @@ func TestIssuesService_ListLabelsByIssue(t *testing.T) { } func TestIssuesService_ListLabelsByIssue_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ListLabelsByIssue(context.Background(), "%", "%", 1, nil) @@ -202,7 +202,7 @@ func TestIssuesService_ListLabelsByIssue_invalidOwner(t *testing.T) { } func TestIssuesService_AddLabelsToIssue(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := []string{"a", "b"} @@ -231,7 +231,7 @@ func TestIssuesService_AddLabelsToIssue(t *testing.T) { } func TestIssuesService_AddLabelsToIssue_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.AddLabelsToIssue(context.Background(), "%", "%", 1, nil) @@ -239,7 +239,7 @@ func TestIssuesService_AddLabelsToIssue_invalidOwner(t *testing.T) { } func TestIssuesService_RemoveLabelForIssue(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels/l", func(w http.ResponseWriter, r *http.Request) { @@ -253,7 +253,7 @@ func TestIssuesService_RemoveLabelForIssue(t *testing.T) { } func TestIssuesService_RemoveLabelForIssue_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Issues.RemoveLabelForIssue(context.Background(), "%", "%", 1, "%") @@ -261,7 +261,7 @@ func TestIssuesService_RemoveLabelForIssue_invalidOwner(t *testing.T) { } func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := []string{"a", "b"} @@ -290,7 +290,7 @@ func TestIssuesService_ReplaceLabelsForIssue(t *testing.T) { } func TestIssuesService_ReplaceLabelsForIssue_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ReplaceLabelsForIssue(context.Background(), "%", "%", 1, nil) @@ -298,7 +298,7 @@ func TestIssuesService_ReplaceLabelsForIssue_invalidOwner(t *testing.T) { } func TestIssuesService_RemoveLabelsForIssue(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -312,7 +312,7 @@ func TestIssuesService_RemoveLabelsForIssue(t *testing.T) { } func TestIssuesService_RemoveLabelsForIssue_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Issues.RemoveLabelsForIssue(context.Background(), "%", "%", 1) @@ -320,7 +320,7 @@ func TestIssuesService_RemoveLabelsForIssue_invalidOwner(t *testing.T) { } func TestIssuesService_ListLabelsForMilestone(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1/labels", func(w http.ResponseWriter, r *http.Request) { @@ -342,7 +342,7 @@ func TestIssuesService_ListLabelsForMilestone(t *testing.T) { } func TestIssuesService_ListLabelsForMilestone_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ListLabelsForMilestone(context.Background(), "%", "%", 1, nil) diff --git a/github/issues_milestones_test.go b/github/issues_milestones_test.go index eb2e57dc025..019f00a8b9b 100644 --- a/github/issues_milestones_test.go +++ b/github/issues_milestones_test.go @@ -15,7 +15,7 @@ import ( ) func TestIssuesService_ListMilestones(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestIssuesService_ListMilestones(t *testing.T) { } func TestIssuesService_ListMilestones_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ListMilestones(context.Background(), "%", "r", nil) @@ -50,7 +50,7 @@ func TestIssuesService_ListMilestones_invalidOwner(t *testing.T) { } func TestIssuesService_GetMilestone(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestIssuesService_GetMilestone(t *testing.T) { } func TestIssuesService_GetMilestone_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.GetMilestone(context.Background(), "%", "r", 1) @@ -78,7 +78,7 @@ func TestIssuesService_GetMilestone_invalidOwner(t *testing.T) { } func TestIssuesService_CreateMilestone(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Milestone{Title: String("t")} @@ -107,7 +107,7 @@ func TestIssuesService_CreateMilestone(t *testing.T) { } func TestIssuesService_CreateMilestone_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.CreateMilestone(context.Background(), "%", "r", nil) @@ -115,7 +115,7 @@ func TestIssuesService_CreateMilestone_invalidOwner(t *testing.T) { } func TestIssuesService_EditMilestone(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Milestone{Title: String("t")} @@ -144,7 +144,7 @@ func TestIssuesService_EditMilestone(t *testing.T) { } func TestIssuesService_EditMilestone_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.EditMilestone(context.Background(), "%", "r", 1, nil) @@ -152,7 +152,7 @@ func TestIssuesService_EditMilestone_invalidOwner(t *testing.T) { } func TestIssuesService_DeleteMilestone(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/milestones/1", func(w http.ResponseWriter, r *http.Request) { @@ -166,7 +166,7 @@ func TestIssuesService_DeleteMilestone(t *testing.T) { } func TestIssuesService_DeleteMilestone_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Issues.DeleteMilestone(context.Background(), "%", "r", 1) diff --git a/github/issues_test.go b/github/issues_test.go index 55684a3c750..26937d2f43f 100644 --- a/github/issues_test.go +++ b/github/issues_test.go @@ -16,7 +16,7 @@ import ( ) func TestIssuesService_List_all(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/issues", func(w http.ResponseWriter, r *http.Request) { @@ -52,7 +52,7 @@ func TestIssuesService_List_all(t *testing.T) { } func TestIssuesService_List_owned(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/issues", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestIssuesService_List_owned(t *testing.T) { } func TestIssuesService_ListByOrg(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/issues", func(w http.ResponseWriter, r *http.Request) { @@ -94,7 +94,7 @@ func TestIssuesService_ListByOrg(t *testing.T) { } func TestIssuesService_ListByOrg_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ListByOrg(context.Background(), "%", nil) @@ -102,7 +102,7 @@ func TestIssuesService_ListByOrg_invalidOrg(t *testing.T) { } func TestIssuesService_ListByRepo(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues", func(w http.ResponseWriter, r *http.Request) { @@ -139,7 +139,7 @@ func TestIssuesService_ListByRepo(t *testing.T) { } func TestIssuesService_ListByRepo_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.ListByRepo(context.Background(), "%", "r", nil) @@ -147,7 +147,7 @@ func TestIssuesService_ListByRepo_invalidOwner(t *testing.T) { } func TestIssuesService_Get(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1", func(w http.ResponseWriter, r *http.Request) { @@ -175,7 +175,7 @@ func TestIssuesService_Get(t *testing.T) { } func TestIssuesService_Get_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.Get(context.Background(), "%", "r", 1) @@ -183,7 +183,7 @@ func TestIssuesService_Get_invalidOwner(t *testing.T) { } func TestIssuesService_Create(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &IssueRequest{ @@ -217,7 +217,7 @@ func TestIssuesService_Create(t *testing.T) { } func TestIssuesService_Create_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.Create(context.Background(), "%", "r", nil) @@ -225,7 +225,7 @@ func TestIssuesService_Create_invalidOwner(t *testing.T) { } func TestIssuesService_Edit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &IssueRequest{Title: String("t")} @@ -254,7 +254,7 @@ func TestIssuesService_Edit(t *testing.T) { } func TestIssuesService_Edit_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Issues.Edit(context.Background(), "%", "r", 1, nil) @@ -262,7 +262,7 @@ func TestIssuesService_Edit_invalidOwner(t *testing.T) { } func TestIssuesService_Lock(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) { @@ -277,7 +277,7 @@ func TestIssuesService_Lock(t *testing.T) { } func TestIssuesService_Unlock(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/lock", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/issues_timeline_test.go b/github/issues_timeline_test.go index 27f76e02c72..7dc1e856c2c 100644 --- a/github/issues_timeline_test.go +++ b/github/issues_timeline_test.go @@ -14,7 +14,7 @@ import ( ) func TestIssuesService_ListIssueTimeline(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/timeline", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/licenses_test.go b/github/licenses_test.go index c61cd525432..6ab917dc545 100644 --- a/github/licenses_test.go +++ b/github/licenses_test.go @@ -14,7 +14,7 @@ import ( ) func TestLicensesService_List(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/licenses", func(w http.ResponseWriter, r *http.Request) { @@ -41,7 +41,7 @@ func TestLicensesService_List(t *testing.T) { } func TestLicensesService_Get(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/licenses/mit", func(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func TestLicensesService_Get(t *testing.T) { } func TestLicensesService_Get_invalidTemplate(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Licenses.Get(context.Background(), "%") diff --git a/github/migrations_source_import_test.go b/github/migrations_source_import_test.go index dd407e68a32..f06270f3785 100644 --- a/github/migrations_source_import_test.go +++ b/github/migrations_source_import_test.go @@ -15,7 +15,7 @@ import ( ) func TestMigrationService_StartImport(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Import{ @@ -50,7 +50,7 @@ func TestMigrationService_StartImport(t *testing.T) { } func TestMigrationService_ImportProgress(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestMigrationService_ImportProgress(t *testing.T) { } func TestMigrationService_UpdateImport(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Import{ @@ -105,7 +105,7 @@ func TestMigrationService_UpdateImport(t *testing.T) { } func TestMigrationService_CommitAuthors(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import/authors", func(w http.ResponseWriter, r *http.Request) { @@ -128,7 +128,7 @@ func TestMigrationService_CommitAuthors(t *testing.T) { } func TestMigrationService_MapCommitAuthor(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &SourceImportAuthor{Name: String("n"), Email: String("e")} @@ -157,7 +157,7 @@ func TestMigrationService_MapCommitAuthor(t *testing.T) { } func TestMigrationService_SetLFSPreference(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Import{UseLFS: String("opt_in")} @@ -187,7 +187,7 @@ func TestMigrationService_SetLFSPreference(t *testing.T) { } func TestMigrationService_LargeFiles(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import/large_files", func(w http.ResponseWriter, r *http.Request) { @@ -210,7 +210,7 @@ func TestMigrationService_LargeFiles(t *testing.T) { } func TestMigrationService_CancelImport(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/import", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/migrations_test.go b/github/migrations_test.go index 003506e5415..8f0cd2760bd 100644 --- a/github/migrations_test.go +++ b/github/migrations_test.go @@ -15,7 +15,7 @@ import ( ) func TestMigrationService_StartMigration(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestMigrationService_StartMigration(t *testing.T) { } func TestMigrationService_ListMigrations(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations", func(w http.ResponseWriter, r *http.Request) { @@ -61,7 +61,7 @@ func TestMigrationService_ListMigrations(t *testing.T) { } func TestMigrationService_MigrationStatus(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1", func(w http.ResponseWriter, r *http.Request) { @@ -82,7 +82,7 @@ func TestMigrationService_MigrationStatus(t *testing.T) { } func TestMigrationService_MigrationArchiveURL(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) { @@ -108,7 +108,7 @@ func TestMigrationService_MigrationArchiveURL(t *testing.T) { } func TestMigrationService_DeleteMigration(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/archive", func(w http.ResponseWriter, r *http.Request) { @@ -124,7 +124,7 @@ func TestMigrationService_DeleteMigration(t *testing.T) { } func TestMigrationService_UnlockRepo(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/migrations/1/repos/r/lock", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/misc_test.go b/github/misc_test.go index 07cef26e934..924e7b4666e 100644 --- a/github/misc_test.go +++ b/github/misc_test.go @@ -15,7 +15,7 @@ import ( ) func TestMarkdown(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &markdownRequest{ @@ -48,7 +48,7 @@ func TestMarkdown(t *testing.T) { } func TestListEmojis(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/emojis", func(w http.ResponseWriter, r *http.Request) { @@ -68,7 +68,7 @@ func TestListEmojis(t *testing.T) { } func TestListCodesOfConduct(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/codes_of_conduct", func(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func TestListCodesOfConduct(t *testing.T) { } func TestGetCodeOfConduct(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/codes_of_conduct/k", func(w http.ResponseWriter, r *http.Request) { @@ -129,7 +129,7 @@ func TestGetCodeOfConduct(t *testing.T) { } func TestAPIMeta(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/meta", func(w http.ResponseWriter, r *http.Request) { @@ -154,7 +154,7 @@ func TestAPIMeta(t *testing.T) { } func TestOctocat(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := "input" @@ -178,7 +178,7 @@ func TestOctocat(t *testing.T) { } func TestZen(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() output := "sample text" @@ -200,7 +200,7 @@ func TestZen(t *testing.T) { } func TestListServiceHooks(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/hooks", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_hooks_test.go b/github/orgs_hooks_test.go index 29c3de8c5ca..465aabbce24 100644 --- a/github/orgs_hooks_test.go +++ b/github/orgs_hooks_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListHooks(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestOrganizationsService_ListHooks(t *testing.T) { } func TestOrganizationsService_ListHooks_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.ListHooks(context.Background(), "%", nil) @@ -46,7 +46,7 @@ func TestOrganizationsService_ListHooks_invalidOrg(t *testing.T) { } func TestOrganizationsService_GetHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -66,7 +66,7 @@ func TestOrganizationsService_GetHook(t *testing.T) { } func TestOrganizationsService_GetHook_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.GetHook(context.Background(), "%", 1) @@ -74,7 +74,7 @@ func TestOrganizationsService_GetHook_invalidOrg(t *testing.T) { } func TestOrganizationsService_EditHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -103,7 +103,7 @@ func TestOrganizationsService_EditHook(t *testing.T) { } func TestOrganizationsService_EditHook_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.EditHook(context.Background(), "%", 1, nil) @@ -111,7 +111,7 @@ func TestOrganizationsService_EditHook_invalidOrg(t *testing.T) { } func TestOrganizationsService_PingHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestOrganizationsService_PingHook(t *testing.T) { } func TestOrganizationsService_DeleteHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -139,7 +139,7 @@ func TestOrganizationsService_DeleteHook(t *testing.T) { } func TestOrganizationsService_DeleteHook_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Organizations.DeleteHook(context.Background(), "%", 1) diff --git a/github/orgs_members_test.go b/github/orgs_members_test.go index 4cdcee3fdca..8ca5e3bd7a1 100644 --- a/github/orgs_members_test.go +++ b/github/orgs_members_test.go @@ -16,7 +16,7 @@ import ( ) func TestOrganizationsService_ListMembers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members", func(w http.ResponseWriter, r *http.Request) { @@ -47,7 +47,7 @@ func TestOrganizationsService_ListMembers(t *testing.T) { } func TestOrganizationsService_ListMembers_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.ListMembers(context.Background(), "%", nil) @@ -55,7 +55,7 @@ func TestOrganizationsService_ListMembers_invalidOrg(t *testing.T) { } func TestOrganizationsService_ListMembers_public(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members", func(w http.ResponseWriter, r *http.Request) { @@ -76,7 +76,7 @@ func TestOrganizationsService_ListMembers_public(t *testing.T) { } func TestOrganizationsService_IsMember(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -95,7 +95,7 @@ func TestOrganizationsService_IsMember(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsMember_notMember(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -115,7 +115,7 @@ func TestOrganizationsService_IsMember_notMember(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsMember_error(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -133,7 +133,7 @@ func TestOrganizationsService_IsMember_error(t *testing.T) { } func TestOrganizationsService_IsMember_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.IsMember(context.Background(), "%", "u") @@ -141,7 +141,7 @@ func TestOrganizationsService_IsMember_invalidOrg(t *testing.T) { } func TestOrganizationsService_IsPublicMember(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -160,7 +160,7 @@ func TestOrganizationsService_IsPublicMember(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -180,7 +180,7 @@ func TestOrganizationsService_IsPublicMember_notMember(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsPublicMember_error(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -198,7 +198,7 @@ func TestOrganizationsService_IsPublicMember_error(t *testing.T) { } func TestOrganizationsService_IsPublicMember_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.IsPublicMember(context.Background(), "%", "u") @@ -206,7 +206,7 @@ func TestOrganizationsService_IsPublicMember_invalidOrg(t *testing.T) { } func TestOrganizationsService_RemoveMember(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -220,7 +220,7 @@ func TestOrganizationsService_RemoveMember(t *testing.T) { } func TestOrganizationsService_RemoveMember_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Organizations.RemoveMember(context.Background(), "%", "u") @@ -228,7 +228,7 @@ func TestOrganizationsService_RemoveMember_invalidOrg(t *testing.T) { } func TestOrganizationsService_ListOrgMemberships(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/memberships/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -256,7 +256,7 @@ func TestOrganizationsService_ListOrgMemberships(t *testing.T) { } func TestOrganizationsService_GetOrgMembership_AuthenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/memberships/orgs/o", func(w http.ResponseWriter, r *http.Request) { @@ -276,7 +276,7 @@ func TestOrganizationsService_GetOrgMembership_AuthenticatedUser(t *testing.T) { } func TestOrganizationsService_GetOrgMembership_SpecifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -296,7 +296,7 @@ func TestOrganizationsService_GetOrgMembership_SpecifiedUser(t *testing.T) { } func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Membership{State: String("active")} @@ -325,7 +325,7 @@ func TestOrganizationsService_EditOrgMembership_AuthenticatedUser(t *testing.T) } func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Membership{State: String("active")} @@ -354,7 +354,7 @@ func TestOrganizationsService_EditOrgMembership_SpecifiedUser(t *testing.T) { } func TestOrganizationsService_RemoveOrgMembership(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -369,7 +369,7 @@ func TestOrganizationsService_RemoveOrgMembership(t *testing.T) { } func TestOrganizationsService_ListPendingOrgInvitations(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/invitations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_outside_collaborators_test.go b/github/orgs_outside_collaborators_test.go index f5dcd46647a..816db7156f7 100644 --- a/github/orgs_outside_collaborators_test.go +++ b/github/orgs_outside_collaborators_test.go @@ -14,7 +14,7 @@ import ( ) func TestOrganizationsService_ListOutsideCollaborators(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/outside_collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestOrganizationsService_ListOutsideCollaborators(t *testing.T) { } func TestOrganizationsService_ListOutsideCollaborators_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.ListOutsideCollaborators(context.Background(), "%", nil) diff --git a/github/orgs_projects_test.go b/github/orgs_projects_test.go index 92831262791..b829a9cf385 100644 --- a/github/orgs_projects_test.go +++ b/github/orgs_projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListProjects(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/projects", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestOrganizationsService_ListProjects(t *testing.T) { } func TestOrganizationsService_CreateProject(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body."} diff --git a/github/orgs_teams_test.go b/github/orgs_teams_test.go index 059a5257890..7e0832e74ee 100644 --- a/github/orgs_teams_test.go +++ b/github/orgs_teams_test.go @@ -17,7 +17,7 @@ import ( ) func TestOrganizationsService_ListTeams(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/teams", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestOrganizationsService_ListTeams(t *testing.T) { } func TestOrganizationsService_ListTeams_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.ListTeams(context.Background(), "%", nil) @@ -48,7 +48,7 @@ func TestOrganizationsService_ListTeams_invalidOrg(t *testing.T) { } func TestOrganizationsService_GetTeam(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestOrganizationsService_GetTeam(t *testing.T) { } func TestOrganizationService_GetTeam_nestedTeams(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { @@ -93,7 +93,7 @@ func TestOrganizationService_GetTeam_nestedTeams(t *testing.T) { } func TestOrganizationsService_CreateTeam(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &NewTeam{Name: "n", Privacy: String("closed"), RepoNames: []string{"r"}} @@ -123,7 +123,7 @@ func TestOrganizationsService_CreateTeam(t *testing.T) { } func TestOrganizationsService_CreateTeam_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.CreateTeam(context.Background(), "%", nil) @@ -131,7 +131,7 @@ func TestOrganizationsService_CreateTeam_invalidOrg(t *testing.T) { } func TestOrganizationsService_EditTeam(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &NewTeam{Name: "n", Privacy: String("closed")} @@ -161,7 +161,7 @@ func TestOrganizationsService_EditTeam(t *testing.T) { } func TestOrganizationsService_DeleteTeam(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1", func(w http.ResponseWriter, r *http.Request) { @@ -176,7 +176,7 @@ func TestOrganizationsService_DeleteTeam(t *testing.T) { } func TestOrganizationsService_ListChildTeams(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/teams", func(w http.ResponseWriter, r *http.Request) { @@ -199,7 +199,7 @@ func TestOrganizationsService_ListChildTeams(t *testing.T) { } func TestOrganizationsService_ListTeamMembers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members", func(w http.ResponseWriter, r *http.Request) { @@ -222,7 +222,7 @@ func TestOrganizationsService_ListTeamMembers(t *testing.T) { } func TestOrganizationsService_IsTeamMember_true(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -240,7 +240,7 @@ func TestOrganizationsService_IsTeamMember_true(t *testing.T) { // ensure that a 404 response is interpreted as "false" and not an error func TestOrganizationsService_IsTeamMember_false(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -260,7 +260,7 @@ func TestOrganizationsService_IsTeamMember_false(t *testing.T) { // ensure that a 400 response is interpreted as an actual error, and not simply // as "false" like the above case of a 404 func TestOrganizationsService_IsTeamMember_error(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/members/u", func(w http.ResponseWriter, r *http.Request) { @@ -278,7 +278,7 @@ func TestOrganizationsService_IsTeamMember_error(t *testing.T) { } func TestOrganizationsService_IsTeamMember_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.IsTeamMember(context.Background(), 1, "%") @@ -286,7 +286,7 @@ func TestOrganizationsService_IsTeamMember_invalidUser(t *testing.T) { } func TestOrganizationsService_PublicizeMembership(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -301,7 +301,7 @@ func TestOrganizationsService_PublicizeMembership(t *testing.T) { } func TestOrganizationsService_PublicizeMembership_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Organizations.PublicizeMembership(context.Background(), "%", "u") @@ -309,7 +309,7 @@ func TestOrganizationsService_PublicizeMembership_invalidOrg(t *testing.T) { } func TestOrganizationsService_ConcealMembership(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/public_members/u", func(w http.ResponseWriter, r *http.Request) { @@ -324,7 +324,7 @@ func TestOrganizationsService_ConcealMembership(t *testing.T) { } func TestOrganizationsService_ConcealMembership_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Organizations.ConcealMembership(context.Background(), "%", "u") @@ -332,7 +332,7 @@ func TestOrganizationsService_ConcealMembership_invalidOrg(t *testing.T) { } func TestOrganizationsService_ListTeamRepos(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos", func(w http.ResponseWriter, r *http.Request) { @@ -356,7 +356,7 @@ func TestOrganizationsService_ListTeamRepos(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_true(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -378,7 +378,7 @@ func TestOrganizationsService_IsTeamRepo_true(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_false(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -399,7 +399,7 @@ func TestOrganizationsService_IsTeamRepo_false(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_error(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -420,7 +420,7 @@ func TestOrganizationsService_IsTeamRepo_error(t *testing.T) { } func TestOrganizationsService_IsTeamRepo_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.IsTeamRepo(context.Background(), 1, "%", "r") @@ -428,7 +428,7 @@ func TestOrganizationsService_IsTeamRepo_invalidOwner(t *testing.T) { } func TestOrganizationsService_AddTeamRepo(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() opt := &OrganizationAddTeamRepoOptions{Permission: "admin"} @@ -452,7 +452,7 @@ func TestOrganizationsService_AddTeamRepo(t *testing.T) { } func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -467,7 +467,7 @@ func TestOrganizationsService_AddTeamRepo_noAccess(t *testing.T) { } func TestOrganizationsService_AddTeamRepo_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Organizations.AddTeamRepo(context.Background(), 1, "%", "r", nil) @@ -475,7 +475,7 @@ func TestOrganizationsService_AddTeamRepo_invalidOwner(t *testing.T) { } func TestOrganizationsService_RemoveTeamRepo(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -490,7 +490,7 @@ func TestOrganizationsService_RemoveTeamRepo(t *testing.T) { } func TestOrganizationsService_RemoveTeamRepo_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Organizations.RemoveTeamRepo(context.Background(), 1, "%", "r") @@ -498,7 +498,7 @@ func TestOrganizationsService_RemoveTeamRepo_invalidOwner(t *testing.T) { } func TestOrganizationsService_GetTeamMembership(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -519,7 +519,7 @@ func TestOrganizationsService_GetTeamMembership(t *testing.T) { } func TestOrganizationsService_AddTeamMembership(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() opt := &OrganizationAddTeamMembershipOptions{Role: "maintainer"} @@ -548,7 +548,7 @@ func TestOrganizationsService_AddTeamMembership(t *testing.T) { } func TestOrganizationsService_RemoveTeamMembership(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/memberships/u", func(w http.ResponseWriter, r *http.Request) { @@ -563,7 +563,7 @@ func TestOrganizationsService_RemoveTeamMembership(t *testing.T) { } func TestOrganizationsService_ListUserTeams(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/teams", func(w http.ResponseWriter, r *http.Request) { @@ -586,7 +586,7 @@ func TestOrganizationsService_ListUserTeams(t *testing.T) { } func TestOrganizationsService_ListPendingTeamInvitations(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/teams/1/invitations", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/orgs_test.go b/github/orgs_test.go index 87f6ba966e2..90b356ed379 100644 --- a/github/orgs_test.go +++ b/github/orgs_test.go @@ -15,7 +15,7 @@ import ( ) func TestOrganizationsService_ListAll(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() since := 1342004 @@ -38,7 +38,7 @@ func TestOrganizationsService_ListAll(t *testing.T) { } func TestOrganizationsService_List_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestOrganizationsService_List_authenticatedUser(t *testing.T) { } func TestOrganizationsService_List_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/orgs", func(w http.ResponseWriter, r *http.Request) { @@ -80,7 +80,7 @@ func TestOrganizationsService_List_specifiedUser(t *testing.T) { } func TestOrganizationsService_List_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.List(context.Background(), "%", nil) @@ -88,7 +88,7 @@ func TestOrganizationsService_List_invalidUser(t *testing.T) { } func TestOrganizationsService_Get(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) { @@ -108,7 +108,7 @@ func TestOrganizationsService_Get(t *testing.T) { } func TestOrganizationsService_Get_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.Get(context.Background(), "%") @@ -116,7 +116,7 @@ func TestOrganizationsService_Get_invalidOrg(t *testing.T) { } func TestOrganizationsService_GetByID(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/organizations/1", func(w http.ResponseWriter, r *http.Request) { @@ -136,7 +136,7 @@ func TestOrganizationsService_GetByID(t *testing.T) { } func TestOrganizationsService_Edit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Organization{Login: String("l")} @@ -165,7 +165,7 @@ func TestOrganizationsService_Edit(t *testing.T) { } func TestOrganizationsService_Edit_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Organizations.Edit(context.Background(), "%", nil) diff --git a/github/orgs_users_blocking_test.go b/github/orgs_users_blocking_test.go index 8b6bdcd5c0f..5d38cc44ea8 100644 --- a/github/orgs_users_blocking_test.go +++ b/github/orgs_users_blocking_test.go @@ -14,7 +14,7 @@ import ( ) func TestOrganizationsService_ListBlockedUsers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestOrganizationsService_ListBlockedUsers(t *testing.T) { } func TestOrganizationsService_IsBlocked(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestOrganizationsService_IsBlocked(t *testing.T) { } func TestOrganizationsService_BlockUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func TestOrganizationsService_BlockUser(t *testing.T) { } func TestOrganizationsService_UnblockUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/orgs/o/blocks/u", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/projects_test.go b/github/projects_test.go index 2f15ebe706a..6e28f864c98 100644 --- a/github/projects_test.go +++ b/github/projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestProjectsService_UpdateProject(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body.", State: "open"} @@ -45,7 +45,7 @@ func TestProjectsService_UpdateProject(t *testing.T) { } func TestProjectsService_GetProject(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { @@ -66,7 +66,7 @@ func TestProjectsService_GetProject(t *testing.T) { } func TestProjectsService_DeleteProject(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/projects/1", func(w http.ResponseWriter, r *http.Request) { @@ -81,7 +81,7 @@ func TestProjectsService_DeleteProject(t *testing.T) { } func TestProjectsService_ListProjectColumns(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/projects/1/columns", func(w http.ResponseWriter, r *http.Request) { @@ -104,7 +104,7 @@ func TestProjectsService_ListProjectColumns(t *testing.T) { } func TestProjectsService_GetProjectColumn(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestProjectsService_GetProjectColumn(t *testing.T) { } func TestProjectsService_CreateProjectColumn(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectColumnOptions{Name: "Column Name"} @@ -155,7 +155,7 @@ func TestProjectsService_CreateProjectColumn(t *testing.T) { } func TestProjectsService_UpdateProjectColumn(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectColumnOptions{Name: "Column Name"} @@ -185,7 +185,7 @@ func TestProjectsService_UpdateProjectColumn(t *testing.T) { } func TestProjectsService_DeleteProjectColumn(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1", func(w http.ResponseWriter, r *http.Request) { @@ -200,7 +200,7 @@ func TestProjectsService_DeleteProjectColumn(t *testing.T) { } func TestProjectsService_MoveProjectColumn(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectColumnMoveOptions{Position: "after:12345"} @@ -223,7 +223,7 @@ func TestProjectsService_MoveProjectColumn(t *testing.T) { } func TestProjectsService_ListProjectCards(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/1/cards", func(w http.ResponseWriter, r *http.Request) { @@ -246,7 +246,7 @@ func TestProjectsService_ListProjectCards(t *testing.T) { } func TestProjectsService_GetProjectCard(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { @@ -267,7 +267,7 @@ func TestProjectsService_GetProjectCard(t *testing.T) { } func TestProjectsService_CreateProjectCard(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectCardOptions{ @@ -300,7 +300,7 @@ func TestProjectsService_CreateProjectCard(t *testing.T) { } func TestProjectsService_UpdateProjectCard(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectCardOptions{ @@ -333,7 +333,7 @@ func TestProjectsService_UpdateProjectCard(t *testing.T) { } func TestProjectsService_DeleteProjectCard(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/projects/columns/cards/1", func(w http.ResponseWriter, r *http.Request) { @@ -348,7 +348,7 @@ func TestProjectsService_DeleteProjectCard(t *testing.T) { } func TestProjectsService_MoveProjectCard(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectCardMoveOptions{Position: "after:12345"} diff --git a/github/pulls_comments_test.go b/github/pulls_comments_test.go index fbc5d669b47..0a839aaeaba 100644 --- a/github/pulls_comments_test.go +++ b/github/pulls_comments_test.go @@ -16,7 +16,7 @@ import ( ) func TestPullRequestsService_ListComments_allPulls(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments", func(w http.ResponseWriter, r *http.Request) { @@ -49,7 +49,7 @@ func TestPullRequestsService_ListComments_allPulls(t *testing.T) { } func TestPullRequestsService_ListComments_specificPull(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestPullRequestsService_ListComments_specificPull(t *testing.T) { } func TestPullRequestsService_ListComments_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.ListComments(context.Background(), "%", "r", 1, nil) @@ -78,7 +78,7 @@ func TestPullRequestsService_ListComments_invalidOwner(t *testing.T) { } func TestPullRequestsService_GetComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -99,7 +99,7 @@ func TestPullRequestsService_GetComment(t *testing.T) { } func TestPullRequestsService_GetComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.GetComment(context.Background(), "%", "r", 1) @@ -107,7 +107,7 @@ func TestPullRequestsService_GetComment_invalidOwner(t *testing.T) { } func TestPullRequestsService_CreateComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &PullRequestComment{Body: String("b")} @@ -136,7 +136,7 @@ func TestPullRequestsService_CreateComment(t *testing.T) { } func TestPullRequestsService_CreateComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.CreateComment(context.Background(), "%", "r", 1, nil) @@ -144,7 +144,7 @@ func TestPullRequestsService_CreateComment_invalidOwner(t *testing.T) { } func TestPullRequestsService_EditComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &PullRequestComment{Body: String("b")} @@ -173,7 +173,7 @@ func TestPullRequestsService_EditComment(t *testing.T) { } func TestPullRequestsService_EditComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.EditComment(context.Background(), "%", "r", 1, nil) @@ -181,7 +181,7 @@ func TestPullRequestsService_EditComment_invalidOwner(t *testing.T) { } func TestPullRequestsService_DeleteComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -195,7 +195,7 @@ func TestPullRequestsService_DeleteComment(t *testing.T) { } func TestPullRequestsService_DeleteComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.PullRequests.DeleteComment(context.Background(), "%", "r", 1) diff --git a/github/pulls_reviewers_test.go b/github/pulls_reviewers_test.go index f366d0e2a67..d76951e190c 100644 --- a/github/pulls_reviewers_test.go +++ b/github/pulls_reviewers_test.go @@ -14,7 +14,7 @@ import ( ) func TestRequestReviewers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestRequestReviewers(t *testing.T) { } func TestRemoveReviewers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -52,7 +52,7 @@ func TestRemoveReviewers(t *testing.T) { } func TestListReviewers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { @@ -86,7 +86,7 @@ func TestListReviewers(t *testing.T) { } func TestListReviewers_withOptions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index b0590e6d1e2..e9dba35bd6a 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -15,7 +15,7 @@ import ( ) func TestPullRequestsService_ListReviews(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestPullRequestsService_ListReviews(t *testing.T) { } func TestPullRequestsService_ListReviews_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.ListReviews(context.Background(), "%", "r", 1, nil) @@ -50,7 +50,7 @@ func TestPullRequestsService_ListReviews_invalidOwner(t *testing.T) { } func TestPullRequestsService_GetReview(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { @@ -70,7 +70,7 @@ func TestPullRequestsService_GetReview(t *testing.T) { } func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.GetReview(context.Background(), "%", "r", 1, 1) @@ -78,7 +78,7 @@ func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) { } func TestPullRequestsService_DeletePendingReview(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { @@ -98,7 +98,7 @@ func TestPullRequestsService_DeletePendingReview(t *testing.T) { } func TestPullRequestsService_DeletePendingReview_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.DeletePendingReview(context.Background(), "%", "r", 1, 1) @@ -106,7 +106,7 @@ func TestPullRequestsService_DeletePendingReview_invalidOwner(t *testing.T) { } func TestPullRequestsService_ListReviewComments(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -129,7 +129,7 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) { } func TestPullRequestsService_ListReviewComments_withOptions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { @@ -147,7 +147,7 @@ func TestPullRequestsService_ListReviewComments_withOptions(t *testing.T) { } func TestPullRequestsService_ListReviewComments_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.ListReviewComments(context.Background(), "%", "r", 1, 1, nil) @@ -155,7 +155,7 @@ func TestPullRequestsService_ListReviewComments_invalidOwner(t *testing.T) { } func TestPullRequestsService_CreateReview(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &PullRequestReviewRequest{ @@ -188,7 +188,7 @@ func TestPullRequestsService_CreateReview(t *testing.T) { } func TestPullRequestsService_CreateReview_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.CreateReview(context.Background(), "%", "r", 1, &PullRequestReviewRequest{}) @@ -196,7 +196,7 @@ func TestPullRequestsService_CreateReview_invalidOwner(t *testing.T) { } func TestPullRequestsService_SubmitReview(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &PullRequestReviewRequest{ @@ -228,7 +228,7 @@ func TestPullRequestsService_SubmitReview(t *testing.T) { } func TestPullRequestsService_SubmitReview_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.SubmitReview(context.Background(), "%", "r", 1, 1, &PullRequestReviewRequest{}) @@ -236,7 +236,7 @@ func TestPullRequestsService_SubmitReview_invalidOwner(t *testing.T) { } func TestPullRequestsService_DismissReview(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &PullRequestReviewDismissalRequest{Message: String("m")} @@ -265,7 +265,7 @@ func TestPullRequestsService_DismissReview(t *testing.T) { } func TestPullRequestsService_DismissReview_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.DismissReview(context.Background(), "%", "r", 1, 1, &PullRequestReviewDismissalRequest{}) diff --git a/github/pulls_test.go b/github/pulls_test.go index bf82cd5e6ab..fabc7110511 100644 --- a/github/pulls_test.go +++ b/github/pulls_test.go @@ -17,7 +17,7 @@ import ( ) func TestPullRequestsService_List(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) { @@ -46,7 +46,7 @@ func TestPullRequestsService_List(t *testing.T) { } func TestPullRequestsService_List_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.List(context.Background(), "%", "r", nil) @@ -54,7 +54,7 @@ func TestPullRequestsService_List_invalidOwner(t *testing.T) { } func TestPullRequestsService_Get(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func TestPullRequestsService_Get(t *testing.T) { } func TestPullRequestsService_GetRaw_diff(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() const rawStr = "@@diff content" @@ -96,7 +96,7 @@ func TestPullRequestsService_GetRaw_diff(t *testing.T) { } func TestPullRequestsService_GetRaw_patch(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() const rawStr = "@@patch content" @@ -118,7 +118,7 @@ func TestPullRequestsService_GetRaw_patch(t *testing.T) { } func TestPullRequestsService_GetRaw_invalid(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.GetRaw(context.Background(), "o", "r", 1, RawOptions{100}) @@ -131,7 +131,7 @@ func TestPullRequestsService_GetRaw_invalid(t *testing.T) { } func TestPullRequestsService_Get_headAndBase(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -161,7 +161,7 @@ func TestPullRequestsService_Get_headAndBase(t *testing.T) { } func TestPullRequestsService_Get_urlFields(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1", func(w http.ResponseWriter, r *http.Request) { @@ -200,7 +200,7 @@ func TestPullRequestsService_Get_urlFields(t *testing.T) { } func TestPullRequestsService_Get_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.Get(context.Background(), "%", "r", 1) @@ -208,7 +208,7 @@ func TestPullRequestsService_Get_invalidOwner(t *testing.T) { } func TestPullRequestsService_Create(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &NewPullRequest{Title: String("t")} @@ -237,7 +237,7 @@ func TestPullRequestsService_Create(t *testing.T) { } func TestPullRequestsService_Create_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.Create(context.Background(), "%", "r", nil) @@ -245,7 +245,7 @@ func TestPullRequestsService_Create_invalidOwner(t *testing.T) { } func TestPullRequestsService_Edit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() tests := []struct { @@ -298,7 +298,7 @@ func TestPullRequestsService_Edit(t *testing.T) { } func TestPullRequestsService_Edit_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.PullRequests.Edit(context.Background(), "%", "r", 1, &PullRequest{}) @@ -306,7 +306,7 @@ func TestPullRequestsService_Edit_invalidOwner(t *testing.T) { } func TestPullRequestsService_ListCommits(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/commits", func(w http.ResponseWriter, r *http.Request) { @@ -364,7 +364,7 @@ func TestPullRequestsService_ListCommits(t *testing.T) { } func TestPullRequestsService_ListFiles(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/files", func(w http.ResponseWriter, r *http.Request) { @@ -426,7 +426,7 @@ func TestPullRequestsService_ListFiles(t *testing.T) { } func TestPullRequestsService_IsMerged(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) { @@ -446,7 +446,7 @@ func TestPullRequestsService_IsMerged(t *testing.T) { } func TestPullRequestsService_Merge(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/1/merge", func(w http.ResponseWriter, r *http.Request) { @@ -477,7 +477,7 @@ func TestPullRequestsService_Merge(t *testing.T) { // Test that different merge options produce expected PUT requests. See issue https://github.com/google/go-github/issues/500. func TestPullRequestsService_Merge_options(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() tests := []struct { diff --git a/github/reactions_test.go b/github/reactions_test.go index f191fd8bb35..fc3fe7e5295 100644 --- a/github/reactions_test.go +++ b/github/reactions_test.go @@ -13,7 +13,7 @@ import ( ) func TestReactionsService_ListCommentReactions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -34,7 +34,7 @@ func TestReactionsService_ListCommentReactions(t *testing.T) { } func TestReactionsService_CreateCommentReaction(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -56,7 +56,7 @@ func TestReactionsService_CreateCommentReaction(t *testing.T) { } func TestReactionsService_ListIssueReactions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -77,7 +77,7 @@ func TestReactionsService_ListIssueReactions(t *testing.T) { } func TestReactionsService_CreateIssueReaction(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -99,7 +99,7 @@ func TestReactionsService_CreateIssueReaction(t *testing.T) { } func TestReactionsService_ListIssueCommentReactions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -120,7 +120,7 @@ func TestReactionsService_ListIssueCommentReactions(t *testing.T) { } func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/issues/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -142,7 +142,7 @@ func TestReactionsService_CreateIssueCommentReaction(t *testing.T) { } func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -163,7 +163,7 @@ func TestReactionsService_ListPullRequestCommentReactions(t *testing.T) { } func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pulls/comments/1/reactions", func(w http.ResponseWriter, r *http.Request) { @@ -185,7 +185,7 @@ func TestReactionsService_CreatePullRequestCommentReaction(t *testing.T) { } func TestReactionsService_DeleteReaction(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/reactions/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_collaborators_test.go b/github/repos_collaborators_test.go index 6a8d430007b..14be59c173c 100644 --- a/github/repos_collaborators_test.go +++ b/github/repos_collaborators_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListCollaborators(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestRepositoriesService_ListCollaborators(t *testing.T) { } func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators", func(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func TestRepositoriesService_ListCollaborators_withAffiliation(t *testing.T) { } func TestRepositoriesService_ListCollaborators_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListCollaborators(context.Background(), "%", "%", nil) @@ -73,7 +73,7 @@ func TestRepositoriesService_ListCollaborators_invalidOwner(t *testing.T) { } func TestRepositoriesService_IsCollaborator_True(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -92,7 +92,7 @@ func TestRepositoriesService_IsCollaborator_True(t *testing.T) { } func TestRepositoriesService_IsCollaborator_False(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -111,7 +111,7 @@ func TestRepositoriesService_IsCollaborator_False(t *testing.T) { } func TestRepositoriesService_IsCollaborator_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.IsCollaborator(context.Background(), "%", "%", "%") @@ -119,7 +119,7 @@ func TestRepositoriesService_IsCollaborator_invalidUser(t *testing.T) { } func TestRepositoryService_GetPermissionLevel(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u/permission", func(w http.ResponseWriter, r *http.Request) { @@ -145,7 +145,7 @@ func TestRepositoryService_GetPermissionLevel(t *testing.T) { } func TestRepositoriesService_AddCollaborator(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() opt := &RepositoryAddCollaboratorOptions{Permission: "admin"} @@ -170,7 +170,7 @@ func TestRepositoriesService_AddCollaborator(t *testing.T) { } func TestRepositoriesService_AddCollaborator_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Repositories.AddCollaborator(context.Background(), "%", "%", "%", nil) @@ -178,7 +178,7 @@ func TestRepositoriesService_AddCollaborator_invalidUser(t *testing.T) { } func TestRepositoriesService_RemoveCollaborator(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/collaborators/u", func(w http.ResponseWriter, r *http.Request) { @@ -193,7 +193,7 @@ func TestRepositoriesService_RemoveCollaborator(t *testing.T) { } func TestRepositoriesService_RemoveCollaborator_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Repositories.RemoveCollaborator(context.Background(), "%", "%", "%") diff --git a/github/repos_comments_test.go b/github/repos_comments_test.go index 5f6571c1cab..95aa2eca44a 100644 --- a/github/repos_comments_test.go +++ b/github/repos_comments_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListComments(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestRepositoriesService_ListComments(t *testing.T) { } func TestRepositoriesService_ListComments_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListComments(context.Background(), "%", "%", nil) @@ -46,7 +46,7 @@ func TestRepositoriesService_ListComments_invalidOwner(t *testing.T) { } func TestRepositoriesService_ListCommitComments(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/s/comments", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestRepositoriesService_ListCommitComments(t *testing.T) { } func TestRepositoriesService_ListCommitComments_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListCommitComments(context.Background(), "%", "%", "%", nil) @@ -77,7 +77,7 @@ func TestRepositoriesService_ListCommitComments_invalidOwner(t *testing.T) { } func TestRepositoriesService_CreateComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &RepositoryComment{Body: String("b")} @@ -106,7 +106,7 @@ func TestRepositoriesService_CreateComment(t *testing.T) { } func TestRepositoriesService_CreateComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateComment(context.Background(), "%", "%", "%", nil) @@ -114,7 +114,7 @@ func TestRepositoriesService_CreateComment_invalidOwner(t *testing.T) { } func TestRepositoriesService_GetComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -135,7 +135,7 @@ func TestRepositoriesService_GetComment(t *testing.T) { } func TestRepositoriesService_GetComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.GetComment(context.Background(), "%", "%", 1) @@ -143,7 +143,7 @@ func TestRepositoriesService_GetComment_invalidOwner(t *testing.T) { } func TestRepositoriesService_UpdateComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &RepositoryComment{Body: String("b")} @@ -172,7 +172,7 @@ func TestRepositoriesService_UpdateComment(t *testing.T) { } func TestRepositoriesService_UpdateComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.UpdateComment(context.Background(), "%", "%", 1, nil) @@ -180,7 +180,7 @@ func TestRepositoriesService_UpdateComment_invalidOwner(t *testing.T) { } func TestRepositoriesService_DeleteComment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) { @@ -194,7 +194,7 @@ func TestRepositoriesService_DeleteComment(t *testing.T) { } func TestRepositoriesService_DeleteComment_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Repositories.DeleteComment(context.Background(), "%", "%", 1) diff --git a/github/repos_commits_test.go b/github/repos_commits_test.go index 27cdc175d9d..3f7039da2de 100644 --- a/github/repos_commits_test.go +++ b/github/repos_commits_test.go @@ -16,7 +16,7 @@ import ( ) func TestRepositoriesService_ListCommits(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() // given @@ -53,7 +53,7 @@ func TestRepositoriesService_ListCommits(t *testing.T) { } func TestRepositoriesService_GetCommit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/s", func(w http.ResponseWriter, r *http.Request) { @@ -128,7 +128,7 @@ func TestRepositoriesService_GetCommit(t *testing.T) { } func TestRepositoriesService_GetCommitRaw_diff(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() const rawStr = "@@diff content" @@ -150,7 +150,7 @@ func TestRepositoriesService_GetCommitRaw_diff(t *testing.T) { } func TestRepositoriesService_GetCommitRaw_patch(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() const rawStr = "@@patch content" @@ -172,7 +172,7 @@ func TestRepositoriesService_GetCommitRaw_patch(t *testing.T) { } func TestRepositoriesService_GetCommitRaw_invalid(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.GetCommitRaw(context.Background(), "o", "r", "s", RawOptions{100}) @@ -185,7 +185,7 @@ func TestRepositoriesService_GetCommitRaw_invalid(t *testing.T) { } func TestRepositoriesService_GetCommitSHA1(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() const sha1 = "01234abcde" @@ -226,7 +226,7 @@ func TestRepositoriesService_GetCommitSHA1(t *testing.T) { } func TestRepositoriesService_CompareCommits(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/compare/b...h", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_community_health_test.go b/github/repos_community_health_test.go index e3cb9d03d9f..c9499aa1fc6 100644 --- a/github/repos_community_health_test.go +++ b/github/repos_community_health_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_GetCommunityHealthMetrics(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/community/profile", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index cf6323b7f58..0a08e8c70f3 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -68,7 +68,7 @@ func TestRepositoryContent_GetContent(t *testing.T) { } func TestRepositoriesService_GetReadme(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/readme", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -91,14 +91,14 @@ func TestRepositoriesService_GetReadme(t *testing.T) { } func TestRepositoriesService_DownloadContents_Success(t *testing.T) { - serverBaseURL, mux, client, teardown := setup() + client, mux, serverURL, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `[{ "type": "file", "name": "f", - "download_url": "`+serverBaseURL+baseURLPath+`/download/f" + "download_url": "`+serverURL+baseURLPath+`/download/f" }]`) }) mux.HandleFunc("/download/f", func(w http.ResponseWriter, r *http.Request) { @@ -123,7 +123,7 @@ func TestRepositoriesService_DownloadContents_Success(t *testing.T) { } func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -140,7 +140,7 @@ func TestRepositoriesService_DownloadContents_NoDownloadURL(t *testing.T) { } func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/d", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -154,7 +154,7 @@ func TestRepositoriesService_DownloadContents_NoFile(t *testing.T) { } func TestRepositoriesService_GetContents_File(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -177,7 +177,7 @@ func TestRepositoriesService_GetContents_File(t *testing.T) { } func TestRepositoriesService_GetContents_FilenameNeedsEscape(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p#?%/δΈ­.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -190,7 +190,7 @@ func TestRepositoriesService_GetContents_FilenameNeedsEscape(t *testing.T) { } func TestRepositoriesService_GetContents_DirectoryWithSpaces(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/some directory/file.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -203,7 +203,7 @@ func TestRepositoriesService_GetContents_DirectoryWithSpaces(t *testing.T) { } func TestRepositoriesService_GetContents_DirectoryWithPlusChars(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/some directory+name/file.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -216,7 +216,7 @@ func TestRepositoriesService_GetContents_DirectoryWithPlusChars(t *testing.T) { } func TestRepositoriesService_GetContents_Directory(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") @@ -244,7 +244,7 @@ func TestRepositoriesService_GetContents_Directory(t *testing.T) { } func TestRepositoriesService_CreateFile(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -282,7 +282,7 @@ func TestRepositoriesService_CreateFile(t *testing.T) { } func TestRepositoriesService_UpdateFile(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "PUT") @@ -322,7 +322,7 @@ func TestRepositoriesService_UpdateFile(t *testing.T) { } func TestRepositoriesService_DeleteFile(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "DELETE") @@ -358,7 +358,7 @@ func TestRepositoriesService_DeleteFile(t *testing.T) { } func TestRepositoriesService_GetArchiveLink(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/tarball", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") diff --git a/github/repos_deployments_test.go b/github/repos_deployments_test.go index f39c98dff73..d9d4080f628 100644 --- a/github/repos_deployments_test.go +++ b/github/repos_deployments_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListDeployments(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListDeployments(t *testing.T) { } func TestRepositoriesService_GetDeployment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/3", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestRepositoriesService_GetDeployment(t *testing.T) { } func TestRepositoriesService_CreateDeployment(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &DeploymentRequest{Ref: String("1111"), Task: String("deploy"), TransientEnvironment: Bool(true)} @@ -88,7 +88,7 @@ func TestRepositoriesService_CreateDeployment(t *testing.T) { } func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/1/statuses", func(w http.ResponseWriter, r *http.Request) { @@ -110,7 +110,7 @@ func TestRepositoriesService_ListDeploymentStatuses(t *testing.T) { } func TestRepositoriesService_GetDeploymentStatus(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/deployments/3/statuses/4", func(w http.ResponseWriter, r *http.Request) { @@ -131,7 +131,7 @@ func TestRepositoriesService_GetDeploymentStatus(t *testing.T) { } func TestRepositoriesService_CreateDeploymentStatus(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &DeploymentStatusRequest{State: String("inactive"), Description: String("deploy"), AutoInactive: Bool(false)} diff --git a/github/repos_forks_test.go b/github/repos_forks_test.go index 3a0159375ee..e9d9a108b21 100644 --- a/github/repos_forks_test.go +++ b/github/repos_forks_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_ListForks(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { @@ -43,7 +43,7 @@ func TestRepositoriesService_ListForks(t *testing.T) { } func TestRepositoriesService_ListForks_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListForks(context.Background(), "%", "r", nil) @@ -51,7 +51,7 @@ func TestRepositoriesService_ListForks_invalidOwner(t *testing.T) { } func TestRepositoriesService_CreateFork(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/forks", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestRepositoriesService_CreateFork(t *testing.T) { } func TestRepositoriesService_CreateFork_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateFork(context.Background(), "%", "r", nil) diff --git a/github/repos_hooks_test.go b/github/repos_hooks_test.go index 6ccfca35bda..e8e3e1681c9 100644 --- a/github/repos_hooks_test.go +++ b/github/repos_hooks_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_CreateHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -44,7 +44,7 @@ func TestRepositoriesService_CreateHook(t *testing.T) { } func TestRepositoriesService_CreateHook_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateHook(context.Background(), "%", "%", nil) @@ -52,7 +52,7 @@ func TestRepositoriesService_CreateHook_invalidOwner(t *testing.T) { } func TestRepositoriesService_ListHooks(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks", func(w http.ResponseWriter, r *http.Request) { @@ -75,7 +75,7 @@ func TestRepositoriesService_ListHooks(t *testing.T) { } func TestRepositoriesService_ListHooks_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListHooks(context.Background(), "%", "%", nil) @@ -83,7 +83,7 @@ func TestRepositoriesService_ListHooks_invalidOwner(t *testing.T) { } func TestRepositoriesService_GetHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -103,7 +103,7 @@ func TestRepositoriesService_GetHook(t *testing.T) { } func TestRepositoriesService_GetHook_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.GetHook(context.Background(), "%", "%", 1) @@ -111,7 +111,7 @@ func TestRepositoriesService_GetHook_invalidOwner(t *testing.T) { } func TestRepositoriesService_EditHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Hook{Name: String("t")} @@ -140,7 +140,7 @@ func TestRepositoriesService_EditHook(t *testing.T) { } func TestRepositoriesService_EditHook_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.EditHook(context.Background(), "%", "%", 1, nil) @@ -148,7 +148,7 @@ func TestRepositoriesService_EditHook_invalidOwner(t *testing.T) { } func TestRepositoriesService_DeleteHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1", func(w http.ResponseWriter, r *http.Request) { @@ -162,7 +162,7 @@ func TestRepositoriesService_DeleteHook(t *testing.T) { } func TestRepositoriesService_DeleteHook_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Repositories.DeleteHook(context.Background(), "%", "%", 1) @@ -170,7 +170,7 @@ func TestRepositoriesService_DeleteHook_invalidOwner(t *testing.T) { } func TestRepositoriesService_PingHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1/pings", func(w http.ResponseWriter, r *http.Request) { @@ -184,7 +184,7 @@ func TestRepositoriesService_PingHook(t *testing.T) { } func TestRepositoriesService_TestHook(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/hooks/1/tests", func(w http.ResponseWriter, r *http.Request) { @@ -198,7 +198,7 @@ func TestRepositoriesService_TestHook(t *testing.T) { } func TestRepositoriesService_TestHook_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Repositories.TestHook(context.Background(), "%", "%", 1) diff --git a/github/repos_invitations_test.go b/github/repos_invitations_test.go index 0d48c64e5ee..729601f77a5 100644 --- a/github/repos_invitations_test.go +++ b/github/repos_invitations_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_ListInvitations(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListInvitations(t *testing.T) { } func TestRepositoriesService_DeleteInvitation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) { @@ -53,7 +53,7 @@ func TestRepositoriesService_DeleteInvitation(t *testing.T) { } func TestRepositoriesService_UpdateInvitation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/invitations/2", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_keys_test.go b/github/repos_keys_test.go index 090745f20be..33cc1970f15 100644 --- a/github/repos_keys_test.go +++ b/github/repos_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListKeys(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListKeys(t *testing.T) { } func TestRepositoriesService_ListKeys_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListKeys(context.Background(), "%", "%", nil) @@ -45,7 +45,7 @@ func TestRepositoriesService_ListKeys_invalidOwner(t *testing.T) { } func TestRepositoriesService_GetKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -65,7 +65,7 @@ func TestRepositoriesService_GetKey(t *testing.T) { } func TestRepositoriesService_GetKey_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.GetKey(context.Background(), "%", "%", 1) @@ -73,7 +73,7 @@ func TestRepositoriesService_GetKey_invalidOwner(t *testing.T) { } func TestRepositoriesService_CreateKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -102,7 +102,7 @@ func TestRepositoriesService_CreateKey(t *testing.T) { } func TestRepositoriesService_CreateKey_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateKey(context.Background(), "%", "%", nil) @@ -110,7 +110,7 @@ func TestRepositoriesService_CreateKey_invalidOwner(t *testing.T) { } func TestRepositoriesService_EditKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -139,7 +139,7 @@ func TestRepositoriesService_EditKey(t *testing.T) { } func TestRepositoriesService_EditKey_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.EditKey(context.Background(), "%", "%", 1, nil) @@ -147,7 +147,7 @@ func TestRepositoriesService_EditKey_invalidOwner(t *testing.T) { } func TestRepositoriesService_DeleteKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -161,7 +161,7 @@ func TestRepositoriesService_DeleteKey(t *testing.T) { } func TestRepositoriesService_DeleteKey_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Repositories.DeleteKey(context.Background(), "%", "%", 1) diff --git a/github/repos_merging_test.go b/github/repos_merging_test.go index be4f9ed021a..086f24bbc3e 100644 --- a/github/repos_merging_test.go +++ b/github/repos_merging_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_Merge(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &RepositoryMergeRequest{ diff --git a/github/repos_pages_test.go b/github/repos_pages_test.go index d41d54e5e98..21a00f9dd78 100644 --- a/github/repos_pages_test.go +++ b/github/repos_pages_test.go @@ -14,7 +14,7 @@ import ( ) func TestRepositoriesService_GetPagesInfo(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages", func(w http.ResponseWriter, r *http.Request) { @@ -35,7 +35,7 @@ func TestRepositoriesService_GetPagesInfo(t *testing.T) { } func TestRepositoriesService_ListPagesBuilds(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { @@ -55,7 +55,7 @@ func TestRepositoriesService_ListPagesBuilds(t *testing.T) { } func TestRepositoriesService_ListPagesBuilds_withOptions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestRepositoriesService_ListPagesBuilds_withOptions(t *testing.T) { } func TestRepositoriesService_GetLatestPagesBuild(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds/latest", func(w http.ResponseWriter, r *http.Request) { @@ -93,7 +93,7 @@ func TestRepositoriesService_GetLatestPagesBuild(t *testing.T) { } func TestRepositoriesService_GetPageBuild(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds/1", func(w http.ResponseWriter, r *http.Request) { @@ -113,7 +113,7 @@ func TestRepositoriesService_GetPageBuild(t *testing.T) { } func TestRepositoriesService_RequestPageBuild(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/pages/builds", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_projects_test.go b/github/repos_projects_test.go index 663ea8fe811..fe02f378837 100644 --- a/github/repos_projects_test.go +++ b/github/repos_projects_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListProjects(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/projects", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestRepositoriesService_ListProjects(t *testing.T) { } func TestRepositoriesService_CreateProject(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProjectOptions{Name: "Project Name", Body: "Project body."} diff --git a/github/repos_releases_test.go b/github/repos_releases_test.go index 4ca11b1fdd7..b7420e8a108 100644 --- a/github/repos_releases_test.go +++ b/github/repos_releases_test.go @@ -19,7 +19,7 @@ import ( ) func TestRepositoriesService_ListReleases(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases", func(w http.ResponseWriter, r *http.Request) { @@ -40,7 +40,7 @@ func TestRepositoriesService_ListReleases(t *testing.T) { } func TestRepositoriesService_GetRelease(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { @@ -60,7 +60,7 @@ func TestRepositoriesService_GetRelease(t *testing.T) { } func TestRepositoriesService_GetLatestRelease(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/latest", func(w http.ResponseWriter, r *http.Request) { @@ -80,7 +80,7 @@ func TestRepositoriesService_GetLatestRelease(t *testing.T) { } func TestRepositoriesService_GetReleaseByTag(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/tags/foo", func(w http.ResponseWriter, r *http.Request) { @@ -100,7 +100,7 @@ func TestRepositoriesService_GetReleaseByTag(t *testing.T) { } func TestRepositoriesService_CreateRelease(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &RepositoryRelease{Name: String("v1.0")} @@ -128,7 +128,7 @@ func TestRepositoriesService_CreateRelease(t *testing.T) { } func TestRepositoriesService_EditRelease(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &RepositoryRelease{Name: String("n")} @@ -155,7 +155,7 @@ func TestRepositoriesService_EditRelease(t *testing.T) { } func TestRepositoriesService_DeleteRelease(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1", func(w http.ResponseWriter, r *http.Request) { @@ -169,7 +169,7 @@ func TestRepositoriesService_DeleteRelease(t *testing.T) { } func TestRepositoriesService_ListReleaseAssets(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1/assets", func(w http.ResponseWriter, r *http.Request) { @@ -190,7 +190,7 @@ func TestRepositoriesService_ListReleaseAssets(t *testing.T) { } func TestRepositoriesService_GetReleaseAsset(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -209,7 +209,7 @@ func TestRepositoriesService_GetReleaseAsset(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_Stream(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -235,7 +235,7 @@ func TestRepositoriesService_DownloadReleaseAsset_Stream(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_Redirect(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -255,7 +255,7 @@ func TestRepositoriesService_DownloadReleaseAsset_Redirect(t *testing.T) { } func TestRepositoriesService_DownloadReleaseAsset_APIError(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -281,7 +281,7 @@ func TestRepositoriesService_DownloadReleaseAsset_APIError(t *testing.T) { } func TestRepositoriesService_EditReleaseAsset(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ReleaseAsset{Name: String("n")} @@ -308,7 +308,7 @@ func TestRepositoriesService_EditReleaseAsset(t *testing.T) { } func TestRepositoriesService_DeleteReleaseAsset(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/assets/1", func(w http.ResponseWriter, r *http.Request) { @@ -322,7 +322,7 @@ func TestRepositoriesService_DeleteReleaseAsset(t *testing.T) { } func TestRepositoriesService_UploadReleaseAsset(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/releases/1/assets", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_stats_test.go b/github/repos_stats_test.go index 97072478276..db136bcbd8f 100644 --- a/github/repos_stats_test.go +++ b/github/repos_stats_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListContributorsStats(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/contributors", func(w http.ResponseWriter, r *http.Request) { @@ -69,7 +69,7 @@ func TestRepositoriesService_ListContributorsStats(t *testing.T) { } func TestRepositoriesService_ListCommitActivity(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/commit_activity", func(w http.ResponseWriter, r *http.Request) { @@ -105,7 +105,7 @@ func TestRepositoriesService_ListCommitActivity(t *testing.T) { } func TestRepositoriesService_ListCodeFrequency(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/code_frequency", func(w http.ResponseWriter, r *http.Request) { @@ -131,7 +131,7 @@ func TestRepositoriesService_ListCodeFrequency(t *testing.T) { } func TestRepositoriesService_Participation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/participation", func(w http.ResponseWriter, r *http.Request) { @@ -181,7 +181,7 @@ func TestRepositoriesService_Participation(t *testing.T) { } func TestRepositoriesService_ListPunchCard(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/stats/punch_card", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_statuses_test.go b/github/repos_statuses_test.go index da0294bbd69..21cc238cf4d 100644 --- a/github/repos_statuses_test.go +++ b/github/repos_statuses_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListStatuses(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/r/statuses", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestRepositoriesService_ListStatuses(t *testing.T) { } func TestRepositoriesService_ListStatuses_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListStatuses(context.Background(), "%", "r", "r", nil) @@ -45,7 +45,7 @@ func TestRepositoriesService_ListStatuses_invalidOwner(t *testing.T) { } func TestRepositoriesService_CreateStatus(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &RepoStatus{State: String("s"), TargetURL: String("t"), Description: String("d")} @@ -73,7 +73,7 @@ func TestRepositoriesService_CreateStatus(t *testing.T) { } func TestRepositoriesService_CreateStatus_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.CreateStatus(context.Background(), "%", "r", "r", nil) @@ -81,7 +81,7 @@ func TestRepositoriesService_CreateStatus_invalidOwner(t *testing.T) { } func TestRepositoriesService_GetCombinedStatus(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/commits/r/status", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/repos_test.go b/github/repos_test.go index e5ce5d87c8c..573c48ab98b 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -16,7 +16,7 @@ import ( ) func TestRepositoriesService_List_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -38,7 +38,7 @@ func TestRepositoriesService_List_authenticatedUser(t *testing.T) { } func TestRepositoriesService_List_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -74,7 +74,7 @@ func TestRepositoriesService_List_specifiedUser(t *testing.T) { } func TestRepositoriesService_List_specifiedUser_type(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -102,7 +102,7 @@ func TestRepositoriesService_List_specifiedUser_type(t *testing.T) { } func TestRepositoriesService_List_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.List(context.Background(), "%", nil) @@ -110,7 +110,7 @@ func TestRepositoriesService_List_invalidUser(t *testing.T) { } func TestRepositoriesService_ListByOrg(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -137,7 +137,7 @@ func TestRepositoriesService_ListByOrg(t *testing.T) { } func TestRepositoriesService_ListByOrg_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListByOrg(context.Background(), "%", nil) @@ -145,7 +145,7 @@ func TestRepositoriesService_ListByOrg_invalidOrg(t *testing.T) { } func TestRepositoriesService_ListAll(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -169,7 +169,7 @@ func TestRepositoriesService_ListAll(t *testing.T) { } func TestRepositoriesService_Create_user(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Repository{Name: String("n")} @@ -198,7 +198,7 @@ func TestRepositoriesService_Create_user(t *testing.T) { } func TestRepositoriesService_Create_org(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Repository{Name: String("n")} @@ -227,7 +227,7 @@ func TestRepositoriesService_Create_org(t *testing.T) { } func TestRepositoriesService_Create_invalidOrg(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.Create(context.Background(), "%", nil) @@ -235,7 +235,7 @@ func TestRepositoriesService_Create_invalidOrg(t *testing.T) { } func TestRepositoriesService_Get(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() acceptHeaders := []string{mediaTypeLicensesPreview, mediaTypeCodesOfConductPreview, mediaTypeTopicsPreview} @@ -257,7 +257,7 @@ func TestRepositoriesService_Get(t *testing.T) { } func TestRepositoriesService_GetCodeOfConduct(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/community/code_of_conduct", func(w http.ResponseWriter, r *http.Request) { @@ -289,7 +289,7 @@ func TestRepositoriesService_GetCodeOfConduct(t *testing.T) { } func TestRepositoriesService_GetByID(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repositories/1", func(w http.ResponseWriter, r *http.Request) { @@ -310,7 +310,7 @@ func TestRepositoriesService_GetByID(t *testing.T) { } func TestRepositoriesService_Edit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() i := true @@ -339,7 +339,7 @@ func TestRepositoriesService_Edit(t *testing.T) { } func TestRepositoriesService_Delete(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r", func(w http.ResponseWriter, r *http.Request) { @@ -353,7 +353,7 @@ func TestRepositoriesService_Delete(t *testing.T) { } func TestRepositoriesService_Get_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.Get(context.Background(), "%", "r") @@ -361,7 +361,7 @@ func TestRepositoriesService_Get_invalidOwner(t *testing.T) { } func TestRepositoriesService_Edit_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.Edit(context.Background(), "%", "r", nil) @@ -369,7 +369,7 @@ func TestRepositoriesService_Edit_invalidOwner(t *testing.T) { } func TestRepositoriesService_ListContributors(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/contributors", func(w http.ResponseWriter, r *http.Request) { @@ -394,7 +394,7 @@ func TestRepositoriesService_ListContributors(t *testing.T) { } func TestRepositoriesService_ListLanguages(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/languages", func(w http.ResponseWriter, r *http.Request) { @@ -414,7 +414,7 @@ func TestRepositoriesService_ListLanguages(t *testing.T) { } func TestRepositoriesService_ListTeams(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/teams", func(w http.ResponseWriter, r *http.Request) { @@ -437,7 +437,7 @@ func TestRepositoriesService_ListTeams(t *testing.T) { } func TestRepositoriesService_ListTags(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/tags", func(w http.ResponseWriter, r *http.Request) { @@ -469,7 +469,7 @@ func TestRepositoriesService_ListTags(t *testing.T) { } func TestRepositoriesService_ListBranches(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches", func(w http.ResponseWriter, r *http.Request) { @@ -492,7 +492,7 @@ func TestRepositoriesService_ListBranches(t *testing.T) { } func TestRepositoriesService_GetBranch(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b", func(w http.ResponseWriter, r *http.Request) { @@ -523,7 +523,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) { } func TestRepositoriesService_GetBranchProtection(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) { @@ -576,7 +576,7 @@ func TestRepositoriesService_GetBranchProtection(t *testing.T) { } func TestRepositoriesService_UpdateBranchProtection(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &ProtectionRequest{ @@ -646,7 +646,7 @@ func TestRepositoriesService_UpdateBranchProtection(t *testing.T) { } func TestRepositoriesService_RemoveBranchProtection(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection", func(w http.ResponseWriter, r *http.Request) { @@ -662,7 +662,7 @@ func TestRepositoriesService_RemoveBranchProtection(t *testing.T) { } func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Repositories.ListLanguages(context.Background(), "%", "%") @@ -670,7 +670,7 @@ func TestRepositoriesService_ListLanguages_invalidOwner(t *testing.T) { } func TestRepositoriesService_License(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/license", func(w http.ResponseWriter, r *http.Request) { @@ -701,7 +701,7 @@ func TestRepositoriesService_License(t *testing.T) { } func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks", func(w http.ResponseWriter, r *http.Request) { @@ -728,7 +728,7 @@ func TestRepositoriesService_GetRequiredStatusChecks(t *testing.T) { } func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_status_checks/contexts", func(w http.ResponseWriter, r *http.Request) { @@ -752,7 +752,7 @@ func TestRepositoriesService_ListRequiredStatusChecksContexts(t *testing.T) { } func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -785,7 +785,7 @@ func TestRepositoriesService_GetPullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &PullRequestReviewsEnforcementUpdate{ @@ -830,7 +830,7 @@ func TestRepositoriesService_UpdatePullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -859,7 +859,7 @@ func TestRepositoriesService_DisableDismissalRestrictions(t *testing.T) { } func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/required_pull_request_reviews", func(w http.ResponseWriter, r *http.Request) { @@ -875,7 +875,7 @@ func TestRepositoriesService_RemovePullRequestReviewEnforcement(t *testing.T) { } func TestRepositoriesService_GetAdminEnforcement(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -900,7 +900,7 @@ func TestRepositoriesService_GetAdminEnforcement(t *testing.T) { } func TestRepositoriesService_AddAdminEnforcement(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -924,7 +924,7 @@ func TestRepositoriesService_AddAdminEnforcement(t *testing.T) { } func TestRepositoriesService_RemoveAdminEnforcement(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/branches/b/protection/enforce_admins", func(w http.ResponseWriter, r *http.Request) { @@ -954,7 +954,7 @@ func TestPullRequestReviewsEnforcementRequest_MarshalJSON_nilDismissalRestirctio } func TestRepositoriesService_ListAllTopics(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -975,7 +975,7 @@ func TestRepositoriesService_ListAllTopics(t *testing.T) { } func TestRepositoriesService_ListAllTopics_emptyTopics(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -996,7 +996,7 @@ func TestRepositoriesService_ListAllTopics_emptyTopics(t *testing.T) { } func TestRepositoriesService_ReplaceAllTopics(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -1017,7 +1017,7 @@ func TestRepositoriesService_ReplaceAllTopics(t *testing.T) { } func TestRepositoriesService_ReplaceAllTopics_nilSlice(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -1039,7 +1039,7 @@ func TestRepositoriesService_ReplaceAllTopics_nilSlice(t *testing.T) { } func TestRepositoriesService_ReplaceAllTopics_emptySlice(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/topics", func(w http.ResponseWriter, r *http.Request) { @@ -1061,7 +1061,7 @@ func TestRepositoriesService_ReplaceAllTopics_emptySlice(t *testing.T) { } func TestRepositoriesService_Transfer(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := TransferRequest{NewOwner: "a", TeamID: []int{123}} diff --git a/github/repos_traffic_test.go b/github/repos_traffic_test.go index ee3139cc21f..0a2eb4f36d2 100644 --- a/github/repos_traffic_test.go +++ b/github/repos_traffic_test.go @@ -15,7 +15,7 @@ import ( ) func TestRepositoriesService_ListTrafficReferrers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/popular/referrers", func(w http.ResponseWriter, r *http.Request) { @@ -43,7 +43,7 @@ func TestRepositoriesService_ListTrafficReferrers(t *testing.T) { } func TestRepositoriesService_ListTrafficPaths(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/popular/paths", func(w http.ResponseWriter, r *http.Request) { @@ -73,7 +73,7 @@ func TestRepositoriesService_ListTrafficPaths(t *testing.T) { } func TestRepositoriesService_ListTrafficViews(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/views", func(w http.ResponseWriter, r *http.Request) { @@ -109,7 +109,7 @@ func TestRepositoriesService_ListTrafficViews(t *testing.T) { } func TestRepositoriesService_ListTrafficClones(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/repos/o/r/traffic/clones", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/search_test.go b/github/search_test.go index fa0eb65510e..30014a550bd 100644 --- a/github/search_test.go +++ b/github/search_test.go @@ -15,7 +15,7 @@ import ( ) func TestSearchService_Repositories(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/search/repositories", func(w http.ResponseWriter, r *http.Request) { @@ -48,7 +48,7 @@ func TestSearchService_Repositories(t *testing.T) { } func TestSearchService_Commits(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/search/commits", func(w http.ResponseWriter, r *http.Request) { @@ -79,7 +79,7 @@ func TestSearchService_Commits(t *testing.T) { } func TestSearchService_Issues(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) { @@ -112,7 +112,7 @@ func TestSearchService_Issues(t *testing.T) { } func TestSearchService_Issues_withQualifiers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/search/issues", func(w http.ResponseWriter, r *http.Request) { @@ -141,7 +141,7 @@ func TestSearchService_Issues_withQualifiers(t *testing.T) { } func TestSearchService_Users(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/search/users", func(w http.ResponseWriter, r *http.Request) { @@ -174,7 +174,7 @@ func TestSearchService_Users(t *testing.T) { } func TestSearchService_Code(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/search/code", func(w http.ResponseWriter, r *http.Request) { @@ -207,7 +207,7 @@ func TestSearchService_Code(t *testing.T) { } func TestSearchService_CodeTextMatch(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/search/code", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_administration_test.go b/github/users_administration_test.go index 829143c8a27..4b0955e9090 100644 --- a/github/users_administration_test.go +++ b/github/users_administration_test.go @@ -12,7 +12,7 @@ import ( ) func TestUsersService_PromoteSiteAdmin(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/site_admin", func(w http.ResponseWriter, r *http.Request) { @@ -27,7 +27,7 @@ func TestUsersService_PromoteSiteAdmin(t *testing.T) { } func TestUsersService_DemoteSiteAdmin(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/site_admin", func(w http.ResponseWriter, r *http.Request) { @@ -42,7 +42,7 @@ func TestUsersService_DemoteSiteAdmin(t *testing.T) { } func TestUsersService_Suspend(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestUsersService_Suspend(t *testing.T) { } func TestUsersService_Unsuspend(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/suspended", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_blocking_test.go b/github/users_blocking_test.go index 6977c9198d2..83e8e30c83d 100644 --- a/github/users_blocking_test.go +++ b/github/users_blocking_test.go @@ -14,7 +14,7 @@ import ( ) func TestUsersService_ListBlockedUsers(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks", func(w http.ResponseWriter, r *http.Request) { @@ -39,7 +39,7 @@ func TestUsersService_ListBlockedUsers(t *testing.T) { } func TestUsersService_IsBlocked(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -58,7 +58,7 @@ func TestUsersService_IsBlocked(t *testing.T) { } func TestUsersService_BlockUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { @@ -74,7 +74,7 @@ func TestUsersService_BlockUser(t *testing.T) { } func TestUsersService_UnblockUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/blocks/u", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_emails_test.go b/github/users_emails_test.go index 925b2f80428..3f72b409bb1 100644 --- a/github/users_emails_test.go +++ b/github/users_emails_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListEmails(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/emails", func(w http.ResponseWriter, r *http.Request) { @@ -41,7 +41,7 @@ func TestUsersService_ListEmails(t *testing.T) { } func TestUsersService_AddEmails(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := []string{"new@example.com"} @@ -73,7 +73,7 @@ func TestUsersService_AddEmails(t *testing.T) { } func TestUsersService_DeleteEmails(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := []string{"user@example.com"} diff --git a/github/users_followers_test.go b/github/users_followers_test.go index f89e9b1ca60..255efbdab83 100644 --- a/github/users_followers_test.go +++ b/github/users_followers_test.go @@ -14,7 +14,7 @@ import ( ) func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/followers", func(w http.ResponseWriter, r *http.Request) { @@ -36,7 +36,7 @@ func TestUsersService_ListFollowers_authenticatedUser(t *testing.T) { } func TestUsersService_ListFollowers_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/followers", func(w http.ResponseWriter, r *http.Request) { @@ -56,7 +56,7 @@ func TestUsersService_ListFollowers_specifiedUser(t *testing.T) { } func TestUsersService_ListFollowers_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Users.ListFollowers(context.Background(), "%", nil) @@ -64,7 +64,7 @@ func TestUsersService_ListFollowers_invalidUser(t *testing.T) { } func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/following", func(w http.ResponseWriter, r *http.Request) { @@ -86,7 +86,7 @@ func TestUsersService_ListFollowing_authenticatedUser(t *testing.T) { } func TestUsersService_ListFollowing_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following", func(w http.ResponseWriter, r *http.Request) { @@ -106,7 +106,7 @@ func TestUsersService_ListFollowing_specifiedUser(t *testing.T) { } func TestUsersService_ListFollowing_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Users.ListFollowing(context.Background(), "%", nil) @@ -114,7 +114,7 @@ func TestUsersService_ListFollowing_invalidUser(t *testing.T) { } func TestUsersService_IsFollowing_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -132,7 +132,7 @@ func TestUsersService_IsFollowing_authenticatedUser(t *testing.T) { } func TestUsersService_IsFollowing_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -150,7 +150,7 @@ func TestUsersService_IsFollowing_specifiedUser(t *testing.T) { } func TestUsersService_IsFollowing_false(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -168,7 +168,7 @@ func TestUsersService_IsFollowing_false(t *testing.T) { } func TestUsersService_IsFollowing_error(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/following/t", func(w http.ResponseWriter, r *http.Request) { @@ -186,7 +186,7 @@ func TestUsersService_IsFollowing_error(t *testing.T) { } func TestUsersService_IsFollowing_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Users.IsFollowing(context.Background(), "%", "%") @@ -194,7 +194,7 @@ func TestUsersService_IsFollowing_invalidUser(t *testing.T) { } func TestUsersService_Follow(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) { @@ -208,7 +208,7 @@ func TestUsersService_Follow(t *testing.T) { } func TestUsersService_Follow_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Users.Follow(context.Background(), "%") @@ -216,7 +216,7 @@ func TestUsersService_Follow_invalidUser(t *testing.T) { } func TestUsersService_Unfollow(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/following/u", func(w http.ResponseWriter, r *http.Request) { @@ -230,7 +230,7 @@ func TestUsersService_Unfollow(t *testing.T) { } func TestUsersService_Unfollow_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, err := client.Users.Unfollow(context.Background(), "%") diff --git a/github/users_gpg_keys_test.go b/github/users_gpg_keys_test.go index 08f33b179ed..dc89712b4ac 100644 --- a/github/users_gpg_keys_test.go +++ b/github/users_gpg_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListGPGKeys_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys", func(w http.ResponseWriter, r *http.Request) { @@ -38,7 +38,7 @@ func TestUsersService_ListGPGKeys_authenticatedUser(t *testing.T) { } func TestUsersService_ListGPGKeys_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/gpg_keys", func(w http.ResponseWriter, r *http.Request) { @@ -59,7 +59,7 @@ func TestUsersService_ListGPGKeys_specifiedUser(t *testing.T) { } func TestUsersService_ListGPGKeys_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Users.ListGPGKeys(context.Background(), "%", nil) @@ -67,7 +67,7 @@ func TestUsersService_ListGPGKeys_invalidUser(t *testing.T) { } func TestUsersService_GetGPGKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -88,7 +88,7 @@ func TestUsersService_GetGPGKey(t *testing.T) { } func TestUsersService_CreateGPGKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := ` @@ -127,7 +127,7 @@ mQINBFcEd9kBEACo54TDbGhKlXKWMvJgecEUKPPcv7XdnpKdGb3LRw5MvFwT0V0f } func TestUsersService_DeleteGPGKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/gpg_keys/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_keys_test.go b/github/users_keys_test.go index 40a0e0127a7..801f44fdf41 100644 --- a/github/users_keys_test.go +++ b/github/users_keys_test.go @@ -15,7 +15,7 @@ import ( ) func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/keys", func(w http.ResponseWriter, r *http.Request) { @@ -37,7 +37,7 @@ func TestUsersService_ListKeys_authenticatedUser(t *testing.T) { } func TestUsersService_ListKeys_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u/keys", func(w http.ResponseWriter, r *http.Request) { @@ -57,7 +57,7 @@ func TestUsersService_ListKeys_specifiedUser(t *testing.T) { } func TestUsersService_ListKeys_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Users.ListKeys(context.Background(), "%", nil) @@ -65,7 +65,7 @@ func TestUsersService_ListKeys_invalidUser(t *testing.T) { } func TestUsersService_GetKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) { @@ -85,7 +85,7 @@ func TestUsersService_GetKey(t *testing.T) { } func TestUsersService_CreateKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &Key{Key: String("k"), Title: String("t")} @@ -114,7 +114,7 @@ func TestUsersService_CreateKey(t *testing.T) { } func TestUsersService_DeleteKey(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/keys/1", func(w http.ResponseWriter, r *http.Request) { diff --git a/github/users_test.go b/github/users_test.go index c0c13d6d55b..c0c99560c7f 100644 --- a/github/users_test.go +++ b/github/users_test.go @@ -57,7 +57,7 @@ func TestUser_marshall(t *testing.T) { } func TestUsersService_Get_authenticatedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user", func(w http.ResponseWriter, r *http.Request) { @@ -77,7 +77,7 @@ func TestUsersService_Get_authenticatedUser(t *testing.T) { } func TestUsersService_Get_specifiedUser(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users/u", func(w http.ResponseWriter, r *http.Request) { @@ -97,7 +97,7 @@ func TestUsersService_Get_specifiedUser(t *testing.T) { } func TestUsersService_Get_invalidUser(t *testing.T) { - _, _, client, teardown := setup() + client, _, _, teardown := setup() defer teardown() _, _, err := client.Users.Get(context.Background(), "%") @@ -105,7 +105,7 @@ func TestUsersService_Get_invalidUser(t *testing.T) { } func TestUsersService_GetByID(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/1", func(w http.ResponseWriter, r *http.Request) { @@ -125,7 +125,7 @@ func TestUsersService_GetByID(t *testing.T) { } func TestUsersService_Edit(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() input := &User{Name: String("n")} @@ -154,7 +154,7 @@ func TestUsersService_Edit(t *testing.T) { } func TestUsersService_ListAll(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/users", func(w http.ResponseWriter, r *http.Request) { @@ -176,7 +176,7 @@ func TestUsersService_ListAll(t *testing.T) { } func TestUsersService_ListInvitations(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) { @@ -197,7 +197,7 @@ func TestUsersService_ListInvitations(t *testing.T) { } func TestUsersService_ListInvitations_withOptions(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations", func(w http.ResponseWriter, r *http.Request) { @@ -215,7 +215,7 @@ func TestUsersService_ListInvitations_withOptions(t *testing.T) { } } func TestUsersService_AcceptInvitation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) { @@ -230,7 +230,7 @@ func TestUsersService_AcceptInvitation(t *testing.T) { } func TestUsersService_DeclineInvitation(t *testing.T) { - _, mux, client, teardown := setup() + client, mux, _, teardown := setup() defer teardown() mux.HandleFunc("/user/repository_invitations/1", func(w http.ResponseWriter, r *http.Request) { From a825cdeba3106045bb1c501ad935beed14e035b8 Mon Sep 17 00:00:00 2001 From: Chris King Date: Sat, 2 Dec 2017 11:42:24 +0100 Subject: [PATCH 13/13] adds full stop to comment --- github/github_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/github_test.go b/github/github_test.go index a010055eeb1..8f578f82bcc 100644 --- a/github/github_test.go +++ b/github/github_test.go @@ -54,7 +54,7 @@ func setup() (client *Client, mux *http.ServeMux, serverURL string, teardown fun server := httptest.NewServer(apiHandler) // client is the GitHub client being tested and is - // configured to use test server + // configured to use test server. client = NewClient(nil) url, _ := url.Parse(server.URL + baseURLPath + "/") client.BaseURL = url