From 03f8b7170127f1b856d6aaba7ef9434244bcc918 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Fri, 5 Feb 2021 17:16:26 +0200 Subject: [PATCH] Add missing imports; change tests --- access_requests.go | 1 + access_requests_test.go | 16 ++++++------- applications_test.go | 6 ++--- audit_events.go | 1 + award_emojis.go | 1 + boards.go | 1 + branches.go | 1 + branches_test.go | 2 +- broadcast_messages.go | 1 + broadcast_messages_test.go | 10 ++++---- ci_yml_templates.go | 1 + commits.go | 1 + commits_test.go | 12 +++++----- custom_attributes.go | 1 + custom_attributes_test.go | 22 ++++++++--------- deploy_tokens.go | 1 + deploy_tokens_test.go | 14 +++++------ deployments.go | 1 + discussions.go | 1 + environments.go | 1 + environments_test.go | 12 +++++----- epic_issues.go | 5 +++- epics.go | 1 + epics_test.go | 10 ++++---- events.go | 1 + feature_flags.go | 1 + feature_flags_test.go | 4 ++-- freeze_periods.go | 1 + gitignore_templates.go | 1 + gitlab_test.go | 4 ++-- group_badges.go | 1 + group_clusters.go | 1 + group_hooks.go | 1 + group_hooks_test.go | 10 ++++---- group_labels.go | 1 + group_labels_test.go | 14 +++++------ group_members.go | 1 + group_variables.go | 1 + group_variables_test.go | 10 ++++---- groups.go | 1 + groups_badges_test.go | 10 ++++---- groups_test.go | 24 +++++++++---------- instance_clusters.go | 1 + instance_variables.go | 1 + invites.go | 1 + invites_test.go | 12 +++++----- issue_links.go | 1 + issues.go | 1 + issues_statistics.go | 1 + issues_statistics_test.go | 6 ++--- issues_test.go | 42 ++++++++++++++++----------------- jobs.go | 1 + jobs_test.go | 2 +- keys_test.go | 2 +- labels.go | 1 + labels_test.go | 14 +++++------ license.go | 5 +++- merge_request_approvals.go | 1 + merge_request_approvals_test.go | 6 ++--- merge_requests.go | 1 + merge_requests_test.go | 8 +++---- milestones.go | 1 + namespaces.go | 1 + notes.go | 1 + notes_test.go | 2 +- notifications.go | 1 + packages.go | 1 + pages_domains.go | 1 + pipeline_schedules.go | 1 + pipeline_schedules_test.go | 2 +- pipeline_triggers_test.go | 2 +- pipelines.go | 1 + pipelines_test.go | 16 ++++++------- project_badges.go | 1 + project_clusters.go | 1 + project_clusters_test.go | 10 ++++---- project_import_export.go | 1 + project_members.go | 1 + project_mirror.go | 1 + project_snippets.go | 1 + project_variables.go | 1 + projects.go | 1 + projects_test.go | 38 ++++++++++++++--------------- protected_branches_test.go | 8 +++---- protected_tags.go | 1 + protected_tags_test.go | 8 +++---- registry.go | 1 + releaselinks.go | 1 + releaselinks_test.go | 10 ++++---- releases.go | 1 + releases_test.go | 20 ++++++++-------- repositories.go | 1 + resource_label_events.go | 1 + runners.go | 1 + runners_test.go | 20 ++++++++-------- search.go | 1 + search_test.go | 6 ++--- services_test.go | 38 ++++++++++++++--------------- settings.go | 5 +++- settings_test.go | 4 ++-- sidekiq_metrics.go | 5 +++- snippets.go | 1 + system_hooks.go | 1 + tags.go | 1 + tags_test.go | 6 ++--- time_stats.go | 1 + todos.go | 1 + todos_test.go | 6 ++--- users.go | 1 + users_test.go | 30 +++++++++++------------ validate.go | 5 +++- validate_test.go | 6 ++--- version.go | 2 ++ version_test.go | 2 +- wikis.go | 1 + 115 files changed, 341 insertions(+), 258 deletions(-) diff --git a/access_requests.go b/access_requests.go index b2449eeca..ebd6d8485 100644 --- a/access_requests.go +++ b/access_requests.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/access_requests_test.go b/access_requests_test.go index 2cefb81e7..870a0f133 100644 --- a/access_requests_test.go +++ b/access_requests_test.go @@ -31,7 +31,7 @@ func TestListProjectAccessRequests(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/access_requests", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprintf(w, `[ { "id": 1, @@ -98,7 +98,7 @@ func TestListGroupAccessRequests(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/access_requests", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprintf(w, `[ { "id": 1, @@ -165,7 +165,7 @@ func TestRequestProjectAccess(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/access_requests", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprintf(w, `{ "id": 1, "username": "raymond_smith", @@ -212,7 +212,7 @@ func TestRequestGroupAccess(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/access_requests", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprintf(w, `{ "id": 1, "username": "raymond_smith", @@ -259,7 +259,7 @@ func TestApproveProjectAccessRequest(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/access_requests/10/approve", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) var opt ApproveAccessRequestOptions err := json.NewDecoder(r.Body).Decode(&opt) @@ -319,7 +319,7 @@ func TestApproveGroupAccessRequest(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/access_requests/10/approve", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) var opt ApproveAccessRequestOptions err := json.NewDecoder(r.Body).Decode(&opt) @@ -379,7 +379,7 @@ func TestDenyProjectAccessRequest(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/access_requests/10", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) resp, err := client.AccessRequests.DenyProjectAccessRequest(1, 10) @@ -404,7 +404,7 @@ func TestDenyGroupAccessRequest(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/access_requests/10", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) resp, err := client.AccessRequests.DenyGroupAccessRequest(1, 10) diff --git a/applications_test.go b/applications_test.go index ea539f37d..e22996eee 100644 --- a/applications_test.go +++ b/applications_test.go @@ -29,7 +29,7 @@ func TestCreateApplication(t *testing.T) { mux.HandleFunc("/api/v4/applications", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, ` { "id":1, @@ -61,7 +61,7 @@ func TestListApplications(t *testing.T) { mux.HandleFunc("/api/v4/applications", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[ {"id":1}, {"id":2} @@ -89,7 +89,7 @@ func TestDeleteApplication(t *testing.T) { mux.HandleFunc("/api/v4/applications/4", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }, ) diff --git a/audit_events.go b/audit_events.go index 297614627..f2ca08532 100644 --- a/audit_events.go +++ b/audit_events.go @@ -2,6 +2,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/award_emojis.go b/award_emojis.go index 82a412262..ffa675a2e 100644 --- a/award_emojis.go +++ b/award_emojis.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/boards.go b/boards.go index ff633d2e6..cec747a53 100644 --- a/boards.go +++ b/boards.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // IssueBoardsService handles communication with the issue board related diff --git a/branches.go b/branches.go index a026667a4..71285620e 100644 --- a/branches.go +++ b/branches.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) diff --git a/branches_test.go b/branches_test.go index 33e92757e..33d1dba4b 100644 --- a/branches_test.go +++ b/branches_test.go @@ -29,7 +29,7 @@ func TestGetBranch(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/repository/branches/master", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/get_branch.json") }) diff --git a/broadcast_messages.go b/broadcast_messages.go index fd0fbf44b..3271843c3 100644 --- a/broadcast_messages.go +++ b/broadcast_messages.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/broadcast_messages_test.go b/broadcast_messages_test.go index 127e3fd01..0939afe73 100644 --- a/broadcast_messages_test.go +++ b/broadcast_messages_test.go @@ -29,7 +29,7 @@ func TestListBroadcastMessages(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/broadcast_messages", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprintf(w, `[{ "message": "Some Message", "starts_at": "2017-06-26T06:00:00.000Z", @@ -88,7 +88,7 @@ func TestGetBroadcastMessages(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/broadcast_messages/1/", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprintf(w, `{ "message": "Some Message", "starts_at": "2017-06-26T06:00:00.000Z", @@ -130,7 +130,7 @@ func TestCreateBroadcastMessages(t *testing.T) { wantedEndsAt := time.Date(2017, time.June, 27, 12, 59, 0, 0, time.UTC) mux.HandleFunc("/api/v4/broadcast_messages", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprintf(w, `{ "message": "Some Message", "starts_at": "2017-06-26T06:00:00.000Z", @@ -178,7 +178,7 @@ func TestUpdateBroadcastMessages(t *testing.T) { wantedEndsAt := time.Date(2017, time.June, 27, 12, 59, 0, 0, time.UTC) mux.HandleFunc("/api/v4/broadcast_messages/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprintf(w, `{ "message": "Some Message Updated", "starts_at": "2017-06-26T06:00:00.000Z", @@ -223,7 +223,7 @@ func TestDeleteBroadcastMessages(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/broadcast_messages/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.BroadcastMessage.DeleteBroadcastMessage(1) diff --git a/ci_yml_templates.go b/ci_yml_templates.go index 767a40e1c..da447c1ba 100644 --- a/ci_yml_templates.go +++ b/ci_yml_templates.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // CIYMLTemplatesService handles communication with the gitlab diff --git a/commits.go b/commits.go index 7b6cec0eb..befb00224 100644 --- a/commits.go +++ b/commits.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" "time" ) diff --git a/commits_test.go b/commits_test.go index f97256184..5e7f0c913 100644 --- a/commits_test.go +++ b/commits_test.go @@ -37,7 +37,7 @@ func TestGetCommit(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/repository/commits/b0b3a907f41409829b307a28b82fdbd552ee5a27", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/get_commit.json") }) @@ -80,7 +80,7 @@ func TestGetCommitStatuses(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/repository/commits/b0b3a907f41409829b307a28b82fdbd552ee5a27/statuses", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1}]`) }) @@ -107,7 +107,7 @@ func TestSetCommitStatus(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/statuses/b0b3a907f41409829b307a28b82fdbd552ee5a27", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) body, err := ioutil.ReadAll(r.Body) require.NoError(t, err) @@ -147,7 +147,7 @@ func TestRevertCommit_NoOptions(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/repository/commits/b0b3a907f41409829b307a28b82fdbd552ee5a27/revert", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) mustWriteHTTPResponse(t, w, "testdata/get_commit.json") }) @@ -190,7 +190,7 @@ func TestRevertCommit_WithOptions(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/repository/commits/b0b3a907f41409829b307a28b82fdbd552ee5a27/revert", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) testBody(t, r, `{"branch":"release"}`) mustWriteHTTPResponse(t, w, "testdata/get_commit.json") }) @@ -236,7 +236,7 @@ func TestGetGPGSignature(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/repository/commits/b0b3a907f41409829b307a28b82fdbd552ee5a27/signature", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/get_signature.json") }) diff --git a/custom_attributes.go b/custom_attributes.go index c73fd9874..7408c55ae 100644 --- a/custom_attributes.go +++ b/custom_attributes.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // CustomAttributesService handles communication with the group, project and diff --git a/custom_attributes_test.go b/custom_attributes_test.go index 9845699c3..da4a04c61 100644 --- a/custom_attributes_test.go +++ b/custom_attributes_test.go @@ -28,7 +28,7 @@ func TestListCustomUserAttributes(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/users/2/custom_attributes", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"key":"testkey1", "value":"testvalue1"}, {"key":"testkey2", "value":"testvalue2"}]`) }) @@ -49,7 +49,7 @@ func TestListCustomGroupAttributes(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/2/custom_attributes", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"key":"testkey1", "value":"testvalue1"}, {"key":"testkey2", "value":"testvalue2"}]`) }) @@ -70,7 +70,7 @@ func TestListCustomProjectAttributes(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/2/custom_attributes", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"key":"testkey1", "value":"testvalue1"}, {"key":"testkey2", "value":"testvalue2"}]`) }) @@ -91,7 +91,7 @@ func TestGetCustomUserAttribute(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/users/2/custom_attributes/testkey1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"key":"testkey1", "value":"testvalue1"}`) }) @@ -112,7 +112,7 @@ func TestGetCustomGropupAttribute(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/2/custom_attributes/testkey1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"key":"testkey1", "value":"testvalue1"}`) }) @@ -133,7 +133,7 @@ func TestGetCustomProjectAttribute(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/2/custom_attributes/testkey1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"key":"testkey1", "value":"testvalue1"}`) }) @@ -154,7 +154,7 @@ func TestSetCustomUserAttribute(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/users/2/custom_attributes/testkey1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"key":"testkey1", "value":"testvalue1"}`) }) @@ -178,7 +178,7 @@ func TestSetCustomGroupAttribute(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/2/custom_attributes/testkey1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"key":"testkey1", "value":"testvalue1"}`) }) @@ -202,7 +202,7 @@ func TestDeleteCustomUserAttribute(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/users/2/custom_attributes/testkey1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }) @@ -223,7 +223,7 @@ func TestDeleteCustomGroupAttribute(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/2/custom_attributes/testkey1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }) @@ -244,7 +244,7 @@ func TestDeleteCustomProjectAttribute(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/2/custom_attributes/testkey1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }) diff --git a/deploy_tokens.go b/deploy_tokens.go index 5f583eef6..2082f96c6 100644 --- a/deploy_tokens.go +++ b/deploy_tokens.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/deploy_tokens_test.go b/deploy_tokens_test.go index 4822d3ea7..ab2f23274 100644 --- a/deploy_tokens_test.go +++ b/deploy_tokens_test.go @@ -29,7 +29,7 @@ func TestListAllDeployTokens(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/deploy_tokens", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, ` [ { @@ -76,7 +76,7 @@ func TestListProjectDeployTokens(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/deploy_tokens", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, ` [ { @@ -123,7 +123,7 @@ func TestCreateProjectDeployToken(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/5/deploy_tokens", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, ` { "id": 1, @@ -173,7 +173,7 @@ func TestDeleteProjectDeployToken(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/5/deploy_tokens/13", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }) @@ -195,7 +195,7 @@ func TestListGroupDeployTokens(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/deploy_tokens", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, ` [ { @@ -242,7 +242,7 @@ func TestCreateGroupDeployToken(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/5/deploy_tokens", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, ` { "id": 1, @@ -292,7 +292,7 @@ func TestDeleteGroupDeployToken(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/5/deploy_tokens/13", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }) diff --git a/deployments.go b/deployments.go index 6c089e109..c13c2b746 100644 --- a/deployments.go +++ b/deployments.go @@ -17,6 +17,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/discussions.go b/discussions.go index a9411d95b..04b5f8d59 100644 --- a/discussions.go +++ b/discussions.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/environments.go b/environments.go index b1766a1fa..9dd7a1b9b 100644 --- a/environments.go +++ b/environments.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // EnvironmentsService handles communication with the environment related methods diff --git a/environments_test.go b/environments_test.go index aeea059ee..0c04dc9e7 100644 --- a/environments_test.go +++ b/environments_test.go @@ -32,7 +32,7 @@ func TestListEnvironments(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/environments", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/projects/1/environments?page=1&per_page=10") fmt.Fprint(w, `[{"id": 1,"name": "review/fix-foo", "slug": "review-fix-foo-dfjre3", "external_url": "https://review-fix-foo-dfjre3.example.gitlab.com"}]`) }) @@ -53,7 +53,7 @@ func TestGetEnvironment(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/environments/5949167", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1,"name":"test/test"}`) }) @@ -73,7 +73,7 @@ func TestCreateEnvironment(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/environments", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) testURL(t, r, "/api/v4/projects/1/environments") fmt.Fprint(w, `{"id": 1,"name": "deploy", "slug": "deploy", "external_url": "https://deploy.example.gitlab.com"}`) }) @@ -94,7 +94,7 @@ func TestEditEnvironment(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/environments/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) testURL(t, r, "/api/v4/projects/1/environments/1") fmt.Fprint(w, `{"id": 1,"name": "staging", "slug": "staging", "external_url": "https://staging.example.gitlab.com"}`) }) @@ -115,7 +115,7 @@ func TestDeleteEnvironment(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/environments/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) testURL(t, r, "/api/v4/projects/1/environments/1") }) _, err := client.Environments.DeleteEnvironment(1, 1) @@ -129,7 +129,7 @@ func TestStopEnvironment(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/environments/1/stop", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) testURL(t, r, "/api/v4/projects/1/environments/1/stop") }) _, err := client.Environments.StopEnvironment(1, 1) diff --git a/epic_issues.go b/epic_issues.go index c7d916683..a3489add8 100644 --- a/epic_issues.go +++ b/epic_issues.go @@ -16,7 +16,10 @@ package gitlab -import "fmt" +import ( + "fmt" + "net/http" +) // EpicIssuesService handles communication with the epic issue related methods // of the GitLab API. diff --git a/epics.go b/epics.go index fd303fe5e..15002a11d 100644 --- a/epics.go +++ b/epics.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/epics_test.go b/epics_test.go index e0a89eabc..578addfdd 100644 --- a/epics_test.go +++ b/epics_test.go @@ -29,7 +29,7 @@ func TestGetEpic(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/7/epics/8", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":8, "title": "Incredible idea", "description": "This is a test epic", "author" : {"id" : 26, "name": "jramsay"}}`) }) @@ -55,7 +55,7 @@ func TestDeleteEpic(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/7/epics/8", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Epics.DeleteEpic("7", 8) @@ -69,7 +69,7 @@ func TestListGroupEpics(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/7/epics", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/groups/7/epics?author_id=26&state=opened") fmt.Fprint(w, `[{"id":8, "title": "Incredible idea", "description": "This is a test epic", "author" : {"id" : 26, "name": "jramsay"}}]`) }) @@ -101,7 +101,7 @@ func TestCreateEpic(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/7/epics", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":8, "title": "Incredible idea", "description": "This is a test epic", "author" : {"id" : 26, "name": "jramsay"}}`) }) @@ -132,7 +132,7 @@ func TestUpdateEpic(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/7/epics/8", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"id":8, "title": "Incredible idea", "description": "This is a test epic", "author" : {"id" : 26, "name": "jramsay"}}`) }) diff --git a/events.go b/events.go index a39e1ccf3..8fec14c4e 100644 --- a/events.go +++ b/events.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/feature_flags.go b/feature_flags.go index 7e5952788..2bf579c24 100644 --- a/feature_flags.go +++ b/feature_flags.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) diff --git a/feature_flags_test.go b/feature_flags_test.go index 3b56d2415..58b808cd2 100644 --- a/feature_flags_test.go +++ b/feature_flags_test.go @@ -28,7 +28,7 @@ func TestListFeatureFlags(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/features", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, ` [ { @@ -70,7 +70,7 @@ func TestSetFeatureFlag(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/features/new_library", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, ` { "name": "new_library", diff --git a/freeze_periods.go b/freeze_periods.go index c23d2c9fb..dfcca0789 100644 --- a/freeze_periods.go +++ b/freeze_periods.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/gitignore_templates.go b/gitignore_templates.go index 4899f1f91..bf066c9e6 100644 --- a/gitignore_templates.go +++ b/gitignore_templates.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) diff --git a/gitlab_test.go b/gitlab_test.go index 81b883a05..17f0d21e6 100644 --- a/gitlab_test.go +++ b/gitlab_test.go @@ -125,7 +125,7 @@ func TestCheckResponse(t *testing.T) { t.Fatalf("Failed to create client: %v", err) } - req, err := c.NewRequest("GET", "test", nil, nil) + req, err := c.NewRequest(http.MethodGet, "test", nil, nil) if err != nil { t.Fatalf("Failed to create request: %v", err) } @@ -178,7 +178,7 @@ func TestRequestWithContext(t *testing.T) { } ctx, cancel := context.WithCancel(context.Background()) - req, err := c.NewRequest("GET", "test", nil, []RequestOptionFunc{WithContext(ctx)}) + req, err := c.NewRequest(http.MethodGet, "test", nil, []RequestOptionFunc{WithContext(ctx)}) if err != nil { t.Fatalf("Failed to create request: %v", err) } diff --git a/group_badges.go b/group_badges.go index fe277c6f8..964999148 100644 --- a/group_badges.go +++ b/group_badges.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // GroupBadgesService handles communication with the group badges diff --git a/group_clusters.go b/group_clusters.go index 47fb5b3c8..c0e905aa1 100644 --- a/group_clusters.go +++ b/group_clusters.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/group_hooks.go b/group_hooks.go index cca61d2f5..dbc84080c 100644 --- a/group_hooks.go +++ b/group_hooks.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/group_hooks_test.go b/group_hooks_test.go index b07b8899c..0049640ab 100644 --- a/group_hooks_test.go +++ b/group_hooks_test.go @@ -29,7 +29,7 @@ func TestListGroupHooks(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/hooks", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, ` [ { @@ -86,7 +86,7 @@ func TestGetGroupHook(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/hooks/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, ` { "id": 1, @@ -141,7 +141,7 @@ func TestAddGroupHook(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/hooks", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, ` { "id": 1, @@ -202,7 +202,7 @@ func TestEditGroupHook(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/hooks/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, ` { "id": 1, @@ -263,7 +263,7 @@ func TestDeleteGroupHook(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/hooks/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Groups.DeleteGroupHook(1, 1) diff --git a/group_labels.go b/group_labels.go index c58bbd98a..e40b597df 100644 --- a/group_labels.go +++ b/group_labels.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // GroupLabelsService handles communication with the label related methods of the diff --git a/group_labels_test.go b/group_labels_test.go index e939d4b96..8b75c5672 100644 --- a/group_labels_test.go +++ b/group_labels_test.go @@ -29,7 +29,7 @@ func TestCreateGroupGroupLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1, "name": "My GroupLabel", "color" : "#11FF22"}`) }) @@ -53,7 +53,7 @@ func TestDeleteGroupLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) label := &DeleteGroupLabelOptions{ @@ -71,7 +71,7 @@ func TestUpdateGroupLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"id":1, "name": "New GroupLabel", "color" : "#11FF23" , "description":"This is updated label"}`) }) @@ -103,7 +103,7 @@ func TestSubscribeToGroupLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/labels/5/subscribe", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{ "id" : 5, "name" : "bug", "color" : "#d9534f", "description": "Bug reported by user", "open_issues_count": 1, "closed_issues_count": 0, "open_merge_requests_count": 1, "subscribed": true,"priority": null}`) }) @@ -122,7 +122,7 @@ func TestUnsubscribeFromGroupLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/labels/5/unsubscribe", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) }) _, err := client.GroupLabels.UnsubscribeFromGroupLabel("1", "5") @@ -136,7 +136,7 @@ func TestListGroupLabels(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{ "id" : 5, "name" : "bug", "color" : "#d9534f", "description": "Bug reported by user", "open_issues_count": 1, "closed_issues_count": 0, "open_merge_requests_count": 1, "subscribed": true,"priority": null}]`) }) @@ -159,7 +159,7 @@ func TestGetGroupLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/labels/5", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "id" : 5, "name" : "bug", "color" : "#d9534f", "description": "Bug reported by user", "open_issues_count": 1, "closed_issues_count": 0, "open_merge_requests_count": 1, "subscribed": true,"priority": null}`) }) diff --git a/group_members.go b/group_members.go index 72e9be389..6fcd8638a 100644 --- a/group_members.go +++ b/group_members.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // GroupMembersService handles communication with the group members diff --git a/group_variables.go b/group_variables.go index a74f43740..bcc7b4928 100644 --- a/group_variables.go +++ b/group_variables.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) diff --git a/group_variables_test.go b/group_variables_test.go index 473d1f057..287d75b3f 100644 --- a/group_variables_test.go +++ b/group_variables_test.go @@ -29,7 +29,7 @@ func TestListGroupVariabless(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/variables", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}]`) }) @@ -58,7 +58,7 @@ func TestGetGroupVariable(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/variables/TEST_VARIABLE_1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`) }) @@ -80,7 +80,7 @@ func TestCreateGroupVariable(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/variables", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`) }) @@ -108,7 +108,7 @@ func TestDeleteGroupVariable(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/variables/TEST_VARIABLE_1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }) @@ -130,7 +130,7 @@ func TestUpdateGroupVariable(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/variables/TEST_VARIABLE_1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"key": "TEST_VARIABLE_1","value": "test1","protected": false,"masked": true}`) }) diff --git a/groups.go b/groups.go index f335f6c2b..3c547aa23 100644 --- a/groups.go +++ b/groups.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/groups_badges_test.go b/groups_badges_test.go index c35b75c72..d2efcd4b4 100644 --- a/groups_badges_test.go +++ b/groups_badges_test.go @@ -29,7 +29,7 @@ func TestListGroupBadges(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/badges", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1, "kind":"group"},{"id":2, "kind":"group"}]`) }) @@ -50,7 +50,7 @@ func TestGetGroupBadge(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/badges/2", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":2, "kind":"group"}`) }) @@ -71,7 +71,7 @@ func TestAddGroupBadge(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/badges", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":3, "link_url":"LINK", "image_url":"IMAGE", "kind":"group"}`) }) @@ -93,7 +93,7 @@ func TestEditGroupBadge(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/badges/2", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"id":2, "link_url":"NEW_LINK", "image_url":"NEW_IMAGE", "kind":"group"}`) }) @@ -115,7 +115,7 @@ func TestRemoveGroupBadge(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/badges/2", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }, ) diff --git a/groups_test.go b/groups_test.go index b8e1ed6a4..991e11a50 100644 --- a/groups_test.go +++ b/groups_test.go @@ -13,7 +13,7 @@ func TestListGroups(t *testing.T) { mux.HandleFunc("/api/v4/groups", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -34,7 +34,7 @@ func TestGetGroup(t *testing.T) { mux.HandleFunc("/api/v4/groups/g", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id": 1, "name": "g"}`) }) @@ -55,7 +55,7 @@ func TestCreateGroup(t *testing.T) { mux.HandleFunc("/api/v4/groups", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id": 1, "name": "g", "path": "g"}`) }) @@ -81,7 +81,7 @@ func TestTransferGroup(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/projects/2", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprintf(w, `{"id": 1}`) }) @@ -102,7 +102,7 @@ func TestDeleteGroup(t *testing.T) { mux.HandleFunc("/api/v4/groups/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }) @@ -124,7 +124,7 @@ func TestSearchGroup(t *testing.T) { mux.HandleFunc("/api/v4/groups", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id": 1, "name": "Foobar Group"}]`) }) @@ -145,7 +145,7 @@ func TestUpdateGroup(t *testing.T) { mux.HandleFunc("/api/v4/groups/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"id": 1}`) }) @@ -166,7 +166,7 @@ func TestListGroupProjects(t *testing.T) { mux.HandleFunc("/api/v4/groups/22/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -188,7 +188,7 @@ func TestListSubgroups(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/subgroups", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id": 1}, {"id": 2}]`) }) @@ -209,7 +209,7 @@ func TestListGroupLDAPLinks(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/ldap_group_links", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[ { "cn":"gitlab_group_example_30", @@ -252,7 +252,7 @@ func TestAddGroupLDAPLink(t *testing.T) { mux.HandleFunc("/api/v4/groups/1/ldap_group_links", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, ` { "cn":"gitlab_group_example_30", @@ -287,7 +287,7 @@ func TestRestoreGroup(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/restore", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id": 1, "name": "g"}`) }) diff --git a/instance_clusters.go b/instance_clusters.go index e1b622fdd..0014653fe 100644 --- a/instance_clusters.go +++ b/instance_clusters.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/instance_variables.go b/instance_variables.go index 891b2d467..f196a9c0f 100644 --- a/instance_variables.go +++ b/instance_variables.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) diff --git a/invites.go b/invites.go index a05fbeef2..fffbfa35f 100644 --- a/invites.go +++ b/invites.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/invites_test.go b/invites_test.go index 520401954..cad6f3b2e 100644 --- a/invites_test.go +++ b/invites_test.go @@ -12,7 +12,7 @@ func TestListGroupPendingInvites(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/test/invitations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -36,7 +36,7 @@ func TestGroupInvites(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/test/invitations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"status": "success"}`) }) @@ -60,7 +60,7 @@ func TestGroupInvitesError(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/test/invitations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"status": "error","message": {"example@member.org": "Already invited"}}`) }) @@ -84,7 +84,7 @@ func TestListProjectPendingInvites(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/test/invitations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -108,7 +108,7 @@ func TestProjectInvites(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/test/invitations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"status": "success"}`) }) @@ -132,7 +132,7 @@ func TestProjectInvitesError(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/test/invitations", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"status": "error","message": {"example@member.org": "Already invited"}}`) }) diff --git a/issue_links.go b/issue_links.go index 2e0de0193..4d8f89162 100644 --- a/issue_links.go +++ b/issue_links.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // IssueLinksService handles communication with the issue relations related methods diff --git a/issues.go b/issues.go index 3a1a523f1..b7403df55 100644 --- a/issues.go +++ b/issues.go @@ -20,6 +20,7 @@ import ( "bytes" "encoding/json" "fmt" + "net/http" "net/url" "strings" "time" diff --git a/issues_statistics.go b/issues_statistics.go index d4699291c..b9249c6d1 100644 --- a/issues_statistics.go +++ b/issues_statistics.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/issues_statistics_test.go b/issues_statistics_test.go index fa1e90521..75abe25fb 100644 --- a/issues_statistics_test.go +++ b/issues_statistics_test.go @@ -29,7 +29,7 @@ func TestGetIssuesStatistics(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/issues_statistics", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/issues_statistics?assignee_id=1&author_id=1") fmt.Fprint(w, `{"statistics": {"counts": {"all": 20,"closed": 5,"opened": 15}}}`) }) @@ -72,7 +72,7 @@ func TestGetGroupIssuesStatistics(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/issues_statistics", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/groups/1/issues_statistics?assignee_id=1&author_id=1") fmt.Fprint(w, `{"statistics": {"counts": {"all": 20,"closed": 5,"opened": 15}}}`) }) @@ -115,7 +115,7 @@ func TestGetProjectIssuesStatistics(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues_statistics", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/projects/1/issues_statistics?assignee_id=1&author_id=1") fmt.Fprint(w, `{"statistics": {"counts": {"all": 20,"closed": 5,"opened": 15}}}`) }) diff --git a/issues_test.go b/issues_test.go index 354e9870f..f5dec2f80 100644 --- a/issues_test.go +++ b/issues_test.go @@ -31,7 +31,7 @@ func TestGetIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1, "description": "This is test project", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}],"merge_requests_count": 1}`) }) @@ -58,7 +58,7 @@ func TestDeleteIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) fmt.Fprint(w, `{"id":1, "description": "This is test project", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}]}`) }) @@ -73,7 +73,7 @@ func TestMoveIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/11/move", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) mustWriteHTTPResponse(t, w, "testdata/issue_move.json") }) @@ -97,7 +97,7 @@ func TestListIssues(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/issues?assignee_id=2&author_id=1") fmt.Fprint(w, ` [ @@ -151,7 +151,7 @@ func TestListIssuesWithLabelDetails(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/issues?assignee_id=2&author_id=1") fmt.Fprint(w, ` [ @@ -222,7 +222,7 @@ func TestListIssuesSearchInTitle(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/issues?in=title&search=Title") fmt.Fprint(w, ` [ @@ -261,7 +261,7 @@ func TestListIssuesSearchInDescription(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/issues?in=description&search=description") fmt.Fprint(w, ` [ @@ -300,7 +300,7 @@ func TestListProjectIssues(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/projects/1/issues?assignee_id=2&author_id=1") fmt.Fprint(w, `[{"id":1, "description": "This is test project", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}]}]`) }) @@ -331,7 +331,7 @@ func TestListGroupIssues(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/groups/1/issues?assignee_id=2&author_id=1&state=Open") fmt.Fprint(w, `[{"id":1, "description": "This is test project", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}]}]`) }) @@ -364,7 +364,7 @@ func TestCreateIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1, "title" : "Title of issue", "description": "This is description of an issue", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}]}`) }) @@ -397,7 +397,7 @@ func TestUpdateIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"id":1, "title" : "Title of issue", "description": "This is description of an issue", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}]}`) }) @@ -429,7 +429,7 @@ func TestSubscribeToIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/subscribe", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1, "title" : "Title of issue", "description": "This is description of an issue", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}]}`) }) @@ -457,7 +457,7 @@ func TestUnsubscribeFromIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/unsubscribe", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1, "title" : "Title of issue", "description": "This is description of an issue", "author" : {"id" : 1, "name": "snehal"}, "assignees":[{"id":1}]}`) }) @@ -484,7 +484,7 @@ func TestListMergeRequestsClosingIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/closed_by", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/projects/1/issues/5/closed_by?page=1&per_page=10") fmt.Fprint(w, `[{"id":1, "title" : "test merge one"},{"id":2, "title" : "test merge two"}]`) @@ -511,7 +511,7 @@ func TestListMergeRequestsRelatedToIssue(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/related_merge_requests", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/projects/1/issues/5/related_merge_requests?page=1&per_page=10") fmt.Fprint(w, `[{"id":1, "title" : "test merge one"},{"id":2, "title" : "test merge two"}]`) @@ -538,7 +538,7 @@ func TestSetTimeEstimate(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/time_estimate", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"human_time_estimate": "3h 30m", "human_total_time_spent": null, "time_estimate": 12600, "total_time_spent": 0}`) }) @@ -562,7 +562,7 @@ func TestResetTimeEstimate(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/reset_time_estimate", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"human_time_estimate": null, "human_total_time_spent": null, "time_estimate": 0, "total_time_spent": 0}`) }) @@ -582,7 +582,7 @@ func TestAddSpentTime(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/add_spent_time", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) testURL(t, r, "/api/v4/projects/1/issues/5/add_spent_time") fmt.Fprint(w, `{"human_time_estimate": null, "human_total_time_spent": "1h", "time_estimate": 0, "total_time_spent": 3600}`) }) @@ -606,7 +606,7 @@ func TestResetSpentTime(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/reset_spent_time", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) testURL(t, r, "/api/v4/projects/1/issues/5/reset_spent_time") fmt.Fprint(w, `{"human_time_estimate": null, "human_total_time_spent": "", "time_estimate": 0, "total_time_spent": 0}`) }) @@ -627,7 +627,7 @@ func TestGetTimeSpent(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/time_stats", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/projects/1/issues/5/time_stats") fmt.Fprint(w, `{"human_time_estimate": "2h", "human_total_time_spent": "1h", "time_estimate": 7200, "total_time_spent": 3600}`) }) @@ -648,7 +648,7 @@ func TestGetIssueParticipants(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/issues/5/participants", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/projects/1/issues/5/participants") fmt.Fprint(w, `[{"id":1,"name":"User1","username":"User1","state":"active","avatar_url":"","web_url":"https://localhost/User1"}, diff --git a/jobs.go b/jobs.go index 5a8c6bbbf..e6470485e 100644 --- a/jobs.go +++ b/jobs.go @@ -19,6 +19,7 @@ package gitlab import ( "bytes" "fmt" + "net/http" "time" ) diff --git a/jobs_test.go b/jobs_test.go index 9bd619b3d..468a32f11 100644 --- a/jobs_test.go +++ b/jobs_test.go @@ -28,7 +28,7 @@ func TestListPipelineJobs(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipelines/1/jobs", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) diff --git a/keys_test.go b/keys_test.go index 814ecdd0b..3f19161f2 100644 --- a/keys_test.go +++ b/keys_test.go @@ -29,7 +29,7 @@ func TestGetKeyWithUser(t *testing.T) { mux.HandleFunc("/api/v4/keys/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "id": 1, "title": "Sample key 25", diff --git a/labels.go b/labels.go index a85fc5811..c81a1ef80 100644 --- a/labels.go +++ b/labels.go @@ -19,6 +19,7 @@ package gitlab import ( "encoding/json" "fmt" + "net/http" ) // LabelsService handles communication with the label related methods of the diff --git a/labels_test.go b/labels_test.go index 1b7cb09be..bb9a2fc53 100644 --- a/labels_test.go +++ b/labels_test.go @@ -29,7 +29,7 @@ func TestCreateLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1, "name": "My Label", "color" : "#11FF22"}`) }) @@ -54,7 +54,7 @@ func TestDeleteLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) // Delete label @@ -73,7 +73,7 @@ func TestUpdateLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"id":1, "name": "New Label", "color" : "#11FF23" , "description":"This is updated label"}`) }) @@ -106,7 +106,7 @@ func TestSubscribeToLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/labels/5/subscribe", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{ "id" : 5, "name" : "bug", "color" : "#d9534f", "description": "Bug reported by user", "open_issues_count": 1, "closed_issues_count": 0, "open_merge_requests_count": 1, "subscribed": true,"priority": null}`) }) @@ -125,7 +125,7 @@ func TestUnsubscribeFromLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/labels/5/unsubscribe", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) }) _, err := client.Labels.UnsubscribeFromLabel("1", "5") @@ -139,7 +139,7 @@ func TestListLabels(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/labels", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{ "id" : 5, "name" : "bug", "color" : "#d9534f", "description": "Bug reported by user", "open_issues_count": 1, "closed_issues_count": 0, "open_merge_requests_count": 1, "subscribed": true,"priority": null}]`) }) @@ -164,7 +164,7 @@ func TestGetLabel(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/labels/5", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "id" : 5, "name" : "bug", "color" : "#d9534f", "description": "Bug reported by user", "open_issues_count": 1, "closed_issues_count": 0, "open_merge_requests_count": 1, "subscribed": true,"priority": null}`) }) diff --git a/license.go b/license.go index 759f16c90..618fde657 100644 --- a/license.go +++ b/license.go @@ -16,7 +16,10 @@ package gitlab -import "time" +import ( + "net/http" + "time" +) // LicenseService handles communication with the license // related methods of the GitLab API. diff --git a/merge_request_approvals.go b/merge_request_approvals.go index 15a420172..857c9dbd4 100644 --- a/merge_request_approvals.go +++ b/merge_request_approvals.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/merge_request_approvals_test.go b/merge_request_approvals_test.go index 0b8c76a66..7f845f1d1 100644 --- a/merge_request_approvals_test.go +++ b/merge_request_approvals_test.go @@ -28,7 +28,7 @@ func TestGetApprovalState(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/merge_requests/1/approval_state", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "approval_rules_overwritten": true, "rules": [ @@ -182,7 +182,7 @@ func TestGetApprovalRules(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/merge_requests/1/approval_rules", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[ { "id": 1, @@ -308,7 +308,7 @@ func TestCreateApprovalRules(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/merge_requests/1/approval_rules", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{ "id": 1, "name": "security", diff --git a/merge_requests.go b/merge_requests.go index 4f5d60790..0a1909ceb 100644 --- a/merge_requests.go +++ b/merge_requests.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/merge_requests_test.go b/merge_requests_test.go index e5df632c1..11bfd474d 100644 --- a/merge_requests_test.go +++ b/merge_requests_test.go @@ -105,7 +105,7 @@ func TestGetMergeRequest(t *testing.T) { path := "/api/v4/projects/namespace/name/merge_requests/123" mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/get_merge_request.json") }) @@ -150,7 +150,7 @@ func TestListProjectMergeRequests(t *testing.T) { path := "/api/v4/projects/278964/merge_requests" mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testParams(t, r, "with_labels_details=true&with_merge_status_recheck=true") mustWriteHTTPResponse(t, w, "testdata/get_merge_requests.json") }) @@ -190,7 +190,7 @@ func TestCreateMergeRequestPipeline(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/merge_requests/1/pipelines", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1, "status":"pending"}`) }) @@ -209,7 +209,7 @@ func TestGetMergeRequestParticipants(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/merge_requests/5/participants", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) testURL(t, r, "/api/v4/projects/1/merge_requests/5/participants") fmt.Fprint(w, `[{"id":1,"name":"User1","username":"User1","state":"active","avatar_url":"","web_url":"https://localhost/User1"}, diff --git a/milestones.go b/milestones.go index 2d7160f91..6629a399c 100644 --- a/milestones.go +++ b/milestones.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/namespaces.go b/namespaces.go index b39bf808f..420da15bb 100644 --- a/namespaces.go +++ b/namespaces.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // NamespacesService handles communication with the namespace related methods diff --git a/notes.go b/notes.go index 6e43d4d25..28edd73af 100644 --- a/notes.go +++ b/notes.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/notes_test.go b/notes_test.go index 1ae1fff1d..8e6813ff5 100644 --- a/notes_test.go +++ b/notes_test.go @@ -28,7 +28,7 @@ func TestGetEpicNote(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/1/epics/4329/notes/3", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":3,"type":null,"body":"foo bar","attachment":null,"system":false,"noteable_id":4392,"noteable_type":"Epic","resolvable":false,"noteable_iid":null}`) }) diff --git a/notifications.go b/notifications.go index 6c11e2dd2..06385b377 100644 --- a/notifications.go +++ b/notifications.go @@ -19,6 +19,7 @@ package gitlab import ( "errors" "fmt" + "net/http" ) // NotificationSettingsService handles communication with the notification settings diff --git a/packages.go b/packages.go index ce1564698..390ada242 100644 --- a/packages.go +++ b/packages.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/pages_domains.go b/pages_domains.go index 6bd69b2ba..52b6f7bd4 100644 --- a/pages_domains.go +++ b/pages_domains.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/pipeline_schedules.go b/pipeline_schedules.go index 459d8f8d3..8a35ecf08 100644 --- a/pipeline_schedules.go +++ b/pipeline_schedules.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/pipeline_schedules_test.go b/pipeline_schedules_test.go index f5856a511..15f7e9e5d 100644 --- a/pipeline_schedules_test.go +++ b/pipeline_schedules_test.go @@ -27,7 +27,7 @@ func TestRunPipelineSchedule(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipeline_schedules/1/play", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusCreated) fmt.Fprint(w, `{"message": "201 Created"}`) }) diff --git a/pipeline_triggers_test.go b/pipeline_triggers_test.go index 4e664a91e..0cb4415fe 100644 --- a/pipeline_triggers_test.go +++ b/pipeline_triggers_test.go @@ -28,7 +28,7 @@ func TestRunPipeline(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/trigger/pipeline", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1, "status":"pending"}`) }) diff --git a/pipelines.go b/pipelines.go index fc699e132..aedcefd6c 100644 --- a/pipelines.go +++ b/pipelines.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/pipelines_test.go b/pipelines_test.go index 70d9d31ab..0807e0294 100644 --- a/pipelines_test.go +++ b/pipelines_test.go @@ -28,7 +28,7 @@ func TestListProjectPipelines(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipelines", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -49,7 +49,7 @@ func TestGetPipeline(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipelines/5949167", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1,"status":"success"}`) }) @@ -69,7 +69,7 @@ func TestGetPipelineVariables(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipelines/5949167/variables", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"key":"RUN_NIGHTLY_BUILD","variable_type":"env_var","value":"true"},{"key":"foo","value":"bar"}]`) }) @@ -89,7 +89,7 @@ func TestGetPipelineTestReport(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipelines/123456/test_report", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/get_pipeline_testreport.json") }) @@ -191,7 +191,7 @@ func TestCreatePipeline(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipeline", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1, "status":"pending"}`) }) @@ -213,7 +213,7 @@ func TestRetryPipelineBuild(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipelines/5949167/retry", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprintln(w, `{"id":1, "status":"pending"}`) }) @@ -233,7 +233,7 @@ func TestCancelPipelineBuild(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipelines/5949167/cancel", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprintln(w, `{"id":1, "status":"canceled"}`) }) @@ -253,7 +253,7 @@ func TestDeletePipeline(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/pipelines/5949167", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Pipelines.DeletePipeline("1", 5949167) diff --git a/project_badges.go b/project_badges.go index 793c838d4..e575f8ef1 100644 --- a/project_badges.go +++ b/project_badges.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // ProjectBadge represents a project badge. diff --git a/project_clusters.go b/project_clusters.go index 5096ae556..17fd09bb7 100644 --- a/project_clusters.go +++ b/project_clusters.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/project_clusters_test.go b/project_clusters_test.go index 92517109c..4775a5f7d 100644 --- a/project_clusters_test.go +++ b/project_clusters_test.go @@ -28,7 +28,7 @@ func TestListClusters(t *testing.T) { pid := 1234 mux.HandleFunc("/api/v4/projects/1234/clusters", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) response := `[ { "id":18, @@ -85,7 +85,7 @@ func TestGetCluster(t *testing.T) { pid := 1234 mux.HandleFunc("/api/v4/projects/1234/clusters/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) response := `{ "id":18, "name":"cluster-1", @@ -165,7 +165,7 @@ func TestAddCluster(t *testing.T) { pid := 1234 mux.HandleFunc("/api/v4/projects/1234/clusters/user", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) response := `{ "id":24, "name":"cluster-5", @@ -241,7 +241,7 @@ func TestEditCluster(t *testing.T) { pid := 1234 mux.HandleFunc("/api/v4/projects/1234/clusters/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) response := `{ "id":24, "name":"new-cluster-name", @@ -316,7 +316,7 @@ func TestDeleteCluster(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1234/clusters/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusAccepted) }) diff --git a/project_import_export.go b/project_import_export.go index a51fe6873..8c89f4e9d 100644 --- a/project_import_export.go +++ b/project_import_export.go @@ -19,6 +19,7 @@ package gitlab import ( "bytes" "fmt" + "net/http" "time" ) diff --git a/project_members.go b/project_members.go index 10cdfb0f0..4f00a11c1 100644 --- a/project_members.go +++ b/project_members.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // ProjectMembersService handles communication with the project members diff --git a/project_mirror.go b/project_mirror.go index f19dee093..7cfbe6d6a 100644 --- a/project_mirror.go +++ b/project_mirror.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/project_snippets.go b/project_snippets.go index d59523d2c..1ab5e2b2e 100644 --- a/project_snippets.go +++ b/project_snippets.go @@ -19,6 +19,7 @@ package gitlab import ( "bytes" "fmt" + "net/http" ) // ProjectSnippetsService handles communication with the project snippets diff --git a/project_variables.go b/project_variables.go index 71bf7b68b..69ce4873c 100644 --- a/project_variables.go +++ b/project_variables.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) diff --git a/projects.go b/projects.go index d1f2844f4..cc1282b71 100644 --- a/projects.go +++ b/projects.go @@ -22,6 +22,7 @@ import ( "io" "io/ioutil" "mime/multipart" + "net/http" "os" "time" ) diff --git a/projects_test.go b/projects_test.go index 162e31880..b9df37e76 100644 --- a/projects_test.go +++ b/projects_test.go @@ -32,7 +32,7 @@ func TestListProjects(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -62,7 +62,7 @@ func TestListUserProjects(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/users/1/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -93,7 +93,7 @@ func TestListProjectsUsersByID(t *testing.T) { mux.HandleFunc("/api/v4/projects/", func(w http.ResponseWriter, r *http.Request) { testURL(t, r, "/api/v4/projects/1/users?page=2&per_page=3&search=query") - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -119,7 +119,7 @@ func TestListProjectsUsersByName(t *testing.T) { mux.HandleFunc("/api/v4/projects/", func(w http.ResponseWriter, r *http.Request) { testURL(t, r, "/api/v4/projects/namespace%2Fname/users?page=2&per_page=3&search=query") - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -144,7 +144,7 @@ func TestListOwnedProjects(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -175,7 +175,7 @@ func TestListStarredProjects(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -206,7 +206,7 @@ func TestGetProjectByID(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "id": 1, "container_registry_enabled": true, @@ -250,7 +250,7 @@ func TestGetProjectByName(t *testing.T) { mux.HandleFunc("/api/v4/projects/", func(w http.ResponseWriter, r *http.Request) { testURL(t, r, "/api/v4/projects/namespace%2Fname") - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1}`) }) want := &Project{ID: 1} @@ -270,7 +270,7 @@ func TestGetProjectWithOptions(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "id":1, "statistics": { @@ -306,7 +306,7 @@ func TestCreateProject(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"id":1}`) }) @@ -371,7 +371,7 @@ func TestListProjectForks(t *testing.T) { mux.HandleFunc("/api/v4/projects/", func(w http.ResponseWriter, r *http.Request) { testURL(t, r, "/api/v4/projects/namespace%2Fname/forks?archived=true&order_by=name&page=2&per_page=3&search=query&simple=true&sort=asc&visibility=public") - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -400,7 +400,7 @@ func TestShareProjectWithGroup(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/share", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) }) opt := &ShareWithGroupOptions{ @@ -419,7 +419,7 @@ func TestDeleteSharedProjectFromGroup(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/share/2", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Projects.DeleteSharedProjectFromGroup(1, 2) @@ -433,7 +433,7 @@ func TestGetApprovalConfiguration(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/approvals", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{ "approvers": [], "approver_groups": [], @@ -470,7 +470,7 @@ func TestChangeApprovalConfiguration(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/approvals", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) testBody(t, r, `{"approvals_before_merge":3}`) fmt.Fprint(w, `{ "approvers": [], @@ -512,7 +512,7 @@ func TestChangeAllowedApprovers(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/approvers", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) testBody(t, r, `{"approver_ids":[1],"approver_group_ids":[2]}`) fmt.Fprint(w, `{ "approvers": [{"user":{"id":1}}], @@ -573,7 +573,7 @@ func TestForkProject(t *testing.T) { path := "myrepopath" mux.HandleFunc("/api/v4/projects/1/fork", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) testBody(t, r, fmt.Sprintf(`{"namespace":"%s","name":"%s","path":"%s"}`, namespace, name, path)) fmt.Fprint(w, `{"id":2}`) }) @@ -598,7 +598,7 @@ func TestGetProjectApprovalRules(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/approval_rules", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[ { "id": 1, @@ -773,7 +773,7 @@ func TestCreateProjectApprovalRule(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/approval_rules", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{ "id": 1, "name": "security", diff --git a/protected_branches_test.go b/protected_branches_test.go index c95ad399a..622103a02 100644 --- a/protected_branches_test.go +++ b/protected_branches_test.go @@ -28,7 +28,7 @@ func TestListProtectedBranches(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/protected_branches", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[ { "id":1, @@ -79,7 +79,7 @@ func TestListProtectedBranchesWithoutCodeOwnerApproval(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/protected_branches", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[ { "id":1, @@ -129,7 +129,7 @@ func TestProtectRepositoryBranches(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/protected_branches", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, ` { "id":1, @@ -182,7 +182,7 @@ func TestUpdateRepositoryBranches(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/protected_branches/master", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PATCH") + testMethod(t, r, http.MethodPatch) codeApprovalQueryParam := r.URL.Query().Get("code_owner_approval_required") if codeApprovalQueryParam != "true" { t.Errorf("query param code_owner_approval_required should be true but was %s", codeApprovalQueryParam) diff --git a/protected_tags.go b/protected_tags.go index 38dea85ee..628f8a24a 100644 --- a/protected_tags.go +++ b/protected_tags.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // ProtectedTagsService handles communication with the protected tag methods diff --git a/protected_tags_test.go b/protected_tags_test.go index b2f2f1138..66337fad3 100644 --- a/protected_tags_test.go +++ b/protected_tags_test.go @@ -29,7 +29,7 @@ func TestListProtectedTags(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/protected_tags", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"name":"1.0.0", "create_access_levels": [{"access_level": 40, "access_level_description": "Maintainers"}]},{"name":"*-release", "create_access_levels": [{"access_level": 30, "access_level_description": "Developers + Maintainers"}]}]`) }) @@ -67,7 +67,7 @@ func TestGetProtectedTag(t *testing.T) { tagName := "my-awesome-tag" mux.HandleFunc(fmt.Sprintf("/api/v4/projects/1/protected_tags/%s", tagName), func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"name":"my-awesome-tag", "create_access_levels": [{"access_level": 30, "access_level_description": "Developers + Maintainers"}]}`) }) @@ -92,7 +92,7 @@ func TestProtectRepositoryTags(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/protected_tags", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"name":"my-awesome-tag", "create_access_levels": [{"access_level": 30, "access_level_description": "Developers + Maintainers"}]}`) }) @@ -118,7 +118,7 @@ func TestUnprotectRepositoryTags(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/protected_tags/my-awesome-tag", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) resp, err := client.ProtectedTags.UnprotectRepositoryTags(1, "my-awesome-tag") diff --git a/registry.go b/registry.go index 2af005647..356a5abf1 100644 --- a/registry.go +++ b/registry.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/releaselinks.go b/releaselinks.go index 72b1223d2..4ea1af8f3 100644 --- a/releaselinks.go +++ b/releaselinks.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // ReleaseLinksService handles communication with the release link methods diff --git a/releaselinks_test.go b/releaselinks_test.go index 9eb011131..c725a4f1e 100644 --- a/releaselinks_test.go +++ b/releaselinks_test.go @@ -28,7 +28,7 @@ func TestReleaseLinksService_ListReleaseLinks(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1/assets/links", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, exampleReleaseLinkList) }) @@ -53,7 +53,7 @@ func TestReleaseLinksService_CreateReleaseLink(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1/assets/links", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, exampleReleaseLink) }) @@ -78,7 +78,7 @@ func TestReleaseLinksService_GetReleaseLink(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1/assets/links/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, exampleReleaseLink) }) @@ -98,7 +98,7 @@ func TestReleaseLinksService_UpdateReleaseLink(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1/assets/links/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, exampleReleaseLink) }) @@ -122,7 +122,7 @@ func TestReleaseLinksService_DeleteReleaseLink(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1/assets/links/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) fmt.Fprint(w, exampleReleaseLink) }) diff --git a/releases.go b/releases.go index fd699ac12..e4d16524e 100644 --- a/releases.go +++ b/releases.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/releases_test.go b/releases_test.go index 2ce38b8da..15d6989de 100644 --- a/releases_test.go +++ b/releases_test.go @@ -31,7 +31,7 @@ func TestReleasesService_ListReleases(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, exampleReleaseListResponse) }) @@ -51,7 +51,7 @@ func TestReleasesService_GetRelease(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, exampleReleaseResponse) }) @@ -70,7 +70,7 @@ func TestReleasesService_CreateRelease(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) b, err := ioutil.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") @@ -115,7 +115,7 @@ func TestReleasesService_CreateReleaseWithAsset(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) b, err := ioutil.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") @@ -165,7 +165,7 @@ func TestReleasesService_CreateReleaseWithMilestones(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) b, err := ioutil.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") @@ -211,7 +211,7 @@ func TestReleasesService_CreateReleaseWithReleasedAt(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) b, err := ioutil.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") @@ -257,7 +257,7 @@ func TestReleasesService_UpdateRelease(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) b, err := ioutil.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") @@ -293,7 +293,7 @@ func TestReleasesService_UpdateReleaseWithMilestones(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) b, err := ioutil.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") @@ -330,7 +330,7 @@ func TestReleasesService_UpdateReleaseWithReleasedAt(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) b, err := ioutil.ReadAll(r.Body) if err != nil { t.Fatalf("unable to read request body") @@ -367,7 +367,7 @@ func TestReleasesService_DeleteRelease(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/releases/v0.1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) fmt.Fprint(w, exampleReleaseResponse) }) diff --git a/repositories.go b/repositories.go index a15b716d1..b9c99cf7d 100644 --- a/repositories.go +++ b/repositories.go @@ -20,6 +20,7 @@ import ( "bytes" "fmt" "io" + "net/http" "net/url" ) diff --git a/resource_label_events.go b/resource_label_events.go index c5c1d285a..086f887fd 100644 --- a/resource_label_events.go +++ b/resource_label_events.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/runners.go b/runners.go index 2633e1c8e..775eef7f6 100644 --- a/runners.go +++ b/runners.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/runners_test.go b/runners_test.go index a72d611cc..20fb2d6a6 100644 --- a/runners_test.go +++ b/runners_test.go @@ -30,7 +30,7 @@ func TestDisableRunner(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/runners/2", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusNoContent) }) @@ -45,7 +45,7 @@ func TestListRunnersJobs(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/runners/1/jobs", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) @@ -67,7 +67,7 @@ func TestRemoveRunner(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/runners/1", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusNoContent) }) @@ -82,7 +82,7 @@ func TestUpdateRunnersDetails(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/runners/6", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, exampleDetailResponse) }) @@ -104,7 +104,7 @@ func TestGetRunnerDetails(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/runners/6", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, exampleDetailResponse) }) @@ -166,7 +166,7 @@ func TestRegisterNewRunner(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/runners", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusCreated) fmt.Fprint(w, exampleRegisterNewRunner) }) @@ -238,7 +238,7 @@ func TestRegisterNewRunnerInfo(t *testing.T) { } mux.HandleFunc("/api/v4/runners", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusCreated) j, err := json.Marshal(want) if err != nil { @@ -267,7 +267,7 @@ func TestDeleteRegisteredRunner(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/runners", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusNoContent) }) @@ -289,7 +289,7 @@ func TestDeleteRegisteredRunnerByID(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/runners/11111", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) w.WriteHeader(http.StatusNoContent) }) @@ -311,7 +311,7 @@ func TestVerifyRegisteredRunner(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/runners/verify", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusOK) }) diff --git a/search.go b/search.go index 7fc2e8261..6d7520f0c 100644 --- a/search.go +++ b/search.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // SearchService handles communication with the search related methods of the diff --git a/search_test.go b/search_test.go index f62a8fd95..2092a1b9a 100644 --- a/search_test.go +++ b/search_test.go @@ -28,7 +28,7 @@ func TestSearchService_Users(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/search", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/search_users.json") }) @@ -53,7 +53,7 @@ func TestSearchService_UsersByGroup(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/groups/3/-/search", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/search_users.json") }) @@ -78,7 +78,7 @@ func TestSearchService_UsersByProject(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/6/-/search", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/search_users.json") }) diff --git a/services_test.go b/services_test.go index 3df1d9324..8f116fc9c 100644 --- a/services_test.go +++ b/services_test.go @@ -28,7 +28,7 @@ func TestListServices(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) want := []*Service{{ID: 1}, {ID: 2}} @@ -47,7 +47,7 @@ func TestGetDroneCIService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/drone-ci", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1}`) }) want := &DroneCIService{Service: Service{ID: 1}} @@ -66,7 +66,7 @@ func TestSetDroneCIService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/drone-ci", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) }) opt := &SetDroneCIServiceOptions{String("t"), String("u"), Bool(true)} @@ -82,7 +82,7 @@ func TestDeleteDroneCIService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/drone-ci", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Services.DeleteDroneCIService(1) @@ -96,22 +96,22 @@ func TestGetJiraService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/0/services/jira", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1, "properties": {"jira_issue_transition_id": "2"}}`) }) mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1, "properties": {"jira_issue_transition_id": 2}}`) }) mux.HandleFunc("/api/v4/projects/2/services/jira", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1, "properties": {"jira_issue_transition_id": "2,3"}}`) }) mux.HandleFunc("/api/v4/projects/3/services/jira", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1, "properties": {}}`) }) @@ -157,7 +157,7 @@ func TestSetJiraService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) }) opt := &SetJiraServiceOptions{ @@ -184,7 +184,7 @@ func TestDeleteJiraService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/jira", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Services.DeleteJiraService(1) @@ -198,7 +198,7 @@ func TestGetSlackService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/slack", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1}`) }) want := &SlackService{Service: Service{ID: 1}} @@ -217,7 +217,7 @@ func TestSetSlackService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/slack", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) }) opt := &SetSlackServiceOptions{ @@ -237,7 +237,7 @@ func TestDeleteSlackService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/slack", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Services.DeleteSlackService(1) @@ -251,7 +251,7 @@ func TestGetPipelinesEmailService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/pipelines-email", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1}`) }) want := &PipelinesEmailService{Service: Service{ID: 1}} @@ -270,7 +270,7 @@ func TestSetPipelinesEmailService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/pipelines-email", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) }) opt := &SetPipelinesEmailServiceOptions{ @@ -293,7 +293,7 @@ func TestDeletePipelinesEmailService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/pipelines-email", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Services.DeletePipelinesEmailService(1) @@ -307,7 +307,7 @@ func TestCustomIssueTrackerService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/custom-issue-tracker", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id": 1, "title": "5", "push_events": true, "properties": {"new_issue_url":"1", "issues_url": "2", "project_url": "3"}}`) }) want := &CustomIssueTrackerService{ @@ -337,7 +337,7 @@ func TestSetCustomIssueTrackerService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/custom-issue-tracker", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) }) opt := &SetCustomIssueTrackerServiceOptions{ @@ -360,7 +360,7 @@ func TestDeleteCustomIssueTrackerService(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/services/custom-issue-tracker", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "DELETE") + testMethod(t, r, http.MethodDelete) }) _, err := client.Services.DeleteCustomIssueTrackerService(1) diff --git a/settings.go b/settings.go index 3aec52d50..8bda0f335 100644 --- a/settings.go +++ b/settings.go @@ -16,7 +16,10 @@ package gitlab -import "time" +import ( + "net/http" + "time" +) // SettingsService handles communication with the application SettingsService // related methods of the GitLab API. diff --git a/settings_test.go b/settings_test.go index 35018fc81..303fe6f04 100644 --- a/settings_test.go +++ b/settings_test.go @@ -28,7 +28,7 @@ func TestGetSettings(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/application/settings", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"id":1, "default_projects_limit" : 100000}`) }) @@ -48,7 +48,7 @@ func TestUpdateSettings(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/application/settings", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"default_projects_limit" : 100}`) }) diff --git a/sidekiq_metrics.go b/sidekiq_metrics.go index d48ab935d..a60fb6bad 100644 --- a/sidekiq_metrics.go +++ b/sidekiq_metrics.go @@ -16,7 +16,10 @@ package gitlab -import "time" +import ( + "net/http" + "time" +) // SidekiqService handles communication with the sidekiq service // diff --git a/snippets.go b/snippets.go index c754983a0..26468b7fd 100644 --- a/snippets.go +++ b/snippets.go @@ -19,6 +19,7 @@ package gitlab import ( "bytes" "fmt" + "net/http" "time" ) diff --git a/system_hooks.go b/system_hooks.go index 12596b645..bc496fd5b 100644 --- a/system_hooks.go +++ b/system_hooks.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/tags.go b/tags.go index ef323d6c8..e0eb3b1aa 100644 --- a/tags.go +++ b/tags.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" ) diff --git a/tags_test.go b/tags_test.go index 77137b589..41518e234 100644 --- a/tags_test.go +++ b/tags_test.go @@ -28,7 +28,7 @@ func TestTagsService_ListTags(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/repository/tags", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `[{"name": "1.0.0"},{"name": "1.0.1"}]`) }) @@ -51,7 +51,7 @@ func TestTagsService_CreateReleaseNote(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/repository/tags/1.0.0/release", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, `{"tag_name": "1.0.0", "description": "Amazing release. Wow"}`) }) @@ -74,7 +74,7 @@ func TestTagsService_UpdateReleaseNote(t *testing.T) { mux.HandleFunc("/api/v4/projects/1/repository/tags/1.0.0/release", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "PUT") + testMethod(t, r, http.MethodPut) fmt.Fprint(w, `{"tag_name": "1.0.0", "description": "Amazing release. Wow!"}`) }) diff --git a/time_stats.go b/time_stats.go index b9640abbb..dfbc1c897 100644 --- a/time_stats.go +++ b/time_stats.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" ) // timeStatsService handles communication with the time tracking related diff --git a/todos.go b/todos.go index 8f0387f2c..7c8cdd04e 100644 --- a/todos.go +++ b/todos.go @@ -18,6 +18,7 @@ package gitlab import ( "fmt" + "net/http" "time" ) diff --git a/todos_test.go b/todos_test.go index 9a8f5d74b..425d32a7f 100644 --- a/todos_test.go +++ b/todos_test.go @@ -28,7 +28,7 @@ func TestListTodos(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/todos", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/list_todos.json") }) @@ -46,7 +46,7 @@ func TestMarkAllTodosAsDone(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/todos/mark_as_done", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusNoContent) }) @@ -59,7 +59,7 @@ func TestMarkTodoAsDone(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/todos/1/mark_as_done", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) }) _, err := client.Todos.MarkTodoAsDone(1) diff --git a/users.go b/users.go index b13aad7c4..cf172326b 100644 --- a/users.go +++ b/users.go @@ -19,6 +19,7 @@ package gitlab import ( "errors" "fmt" + "net/http" "time" ) diff --git a/users_test.go b/users_test.go index 2e145475f..3fd7e2988 100644 --- a/users_test.go +++ b/users_test.go @@ -32,7 +32,7 @@ func TestBlockUser(t *testing.T) { path := fmt.Sprintf("/%susers/1/block", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusCreated) }) @@ -48,7 +48,7 @@ func TestBlockUser_UserNotFound(t *testing.T) { path := fmt.Sprintf("/%susers/1/block", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusNotFound) }) @@ -64,7 +64,7 @@ func TestBlockUser_BlockPrevented(t *testing.T) { path := fmt.Sprintf("/%susers/1/block", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusForbidden) }) @@ -80,7 +80,7 @@ func TestBlockUser_UnknownError(t *testing.T) { path := fmt.Sprintf("/%susers/1/block", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusTeapot) }) @@ -99,7 +99,7 @@ func TestUnblockUser(t *testing.T) { path := fmt.Sprintf("/%susers/1/unblock", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusCreated) }) @@ -115,7 +115,7 @@ func TestUnblockUser_UserNotFound(t *testing.T) { path := fmt.Sprintf("/%susers/1/unblock", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusNotFound) }) @@ -131,7 +131,7 @@ func TestUnblockUser_UnblockPrevented(t *testing.T) { path := fmt.Sprintf("/%susers/1/unblock", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusForbidden) }) @@ -147,7 +147,7 @@ func TestUnblockUser_UnknownError(t *testing.T) { path := fmt.Sprintf("/%susers/1/unblock", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusTeapot) }) @@ -165,7 +165,7 @@ func TestDeactivateUser(t *testing.T) { path := fmt.Sprintf("/%susers/1/deactivate", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusCreated) }) @@ -181,7 +181,7 @@ func TestDeactivateUser_UserNotFound(t *testing.T) { path := fmt.Sprintf("/%susers/1/deactivate", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusNotFound) }) @@ -197,7 +197,7 @@ func TestDeactivateUser_DeactivatePrevented(t *testing.T) { path := fmt.Sprintf("/%susers/1/deactivate", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusForbidden) }) @@ -213,7 +213,7 @@ func TestActivateUser(t *testing.T) { path := fmt.Sprintf("/%susers/1/activate", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusCreated) }) @@ -229,7 +229,7 @@ func TestActivateUser_ActivatePrevented(t *testing.T) { path := fmt.Sprintf("/%susers/1/activate", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusForbidden) }) @@ -245,7 +245,7 @@ func TestActivateUser_UserNotFound(t *testing.T) { path := fmt.Sprintf("/%susers/1/activate", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) w.WriteHeader(http.StatusNotFound) }) @@ -261,7 +261,7 @@ func TestGetMemberships(t *testing.T) { path := fmt.Sprintf("/%susers/1/memberships", apiVersionPath) mux.HandleFunc(path, func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) mustWriteHTTPResponse(t, w, "testdata/get_user_memberships.json") }) diff --git a/validate.go b/validate.go index b34fbfadc..6881d3884 100644 --- a/validate.go +++ b/validate.go @@ -16,7 +16,10 @@ package gitlab -import "fmt" +import ( + "fmt" + "net/http" +) // ValidateService handles communication with the validation related methods of // the GitLab API. diff --git a/validate_test.go b/validate_test.go index b3cf95ec5..be44b7395 100644 --- a/validate_test.go +++ b/validate_test.go @@ -68,7 +68,7 @@ func TestValidate(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/ci/lint", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, tc.response) }) @@ -130,7 +130,7 @@ func TestValidateProject(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/ci/lint", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, tc.response) }) @@ -202,7 +202,7 @@ func TestValidateProjectNamespace(t *testing.T) { defer teardown(server) mux.HandleFunc("/api/v4/projects/1/ci/lint", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "POST") + testMethod(t, r, http.MethodPost) fmt.Fprint(w, tc.response) }) diff --git a/version.go b/version.go index a3984059a..1a7766e84 100644 --- a/version.go +++ b/version.go @@ -16,6 +16,8 @@ package gitlab +import "net/http" + // VersionService handles communication with the GitLab server instance to // retrieve its version information via the GitLab API. // diff --git a/version_test.go b/version_test.go index 93d6c843e..bf75d1c7a 100644 --- a/version_test.go +++ b/version_test.go @@ -29,7 +29,7 @@ func TestGetVersion(t *testing.T) { mux.HandleFunc("/api/v4/version", func(w http.ResponseWriter, r *http.Request) { - testMethod(t, r, "GET") + testMethod(t, r, http.MethodGet) fmt.Fprint(w, `{"version":"11.3.4-ee", "revision":"14d3a1d"}`) }) diff --git a/wikis.go b/wikis.go index 6d9b8d669..e606ecf41 100644 --- a/wikis.go +++ b/wikis.go @@ -17,6 +17,7 @@ package gitlab import ( "fmt" + "net/http" "net/url" )