Skip to content

Commit

Permalink
Add missing imports; change tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Feb 5, 2021
1 parent 104d81d commit 03f8b71
Show file tree
Hide file tree
Showing 115 changed files with 341 additions and 258 deletions.
1 change: 1 addition & 0 deletions access_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
"time"
)

Expand Down
16 changes: 8 additions & 8 deletions access_requests_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions applications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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)
},
)
Expand Down
1 change: 1 addition & 0 deletions audit_events.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package gitlab

import (
"fmt"
"net/http"
"time"
)

Expand Down
1 change: 1 addition & 0 deletions award_emojis.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
"time"
)

Expand Down
1 change: 1 addition & 0 deletions boards.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
)

// IssueBoardsService handles communication with the issue board related
Expand Down
1 change: 1 addition & 0 deletions branches.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
"net/url"
)

Expand Down
2 changes: 1 addition & 1 deletion branches_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

Expand Down
1 change: 1 addition & 0 deletions broadcast_messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
"time"
)

Expand Down
10 changes: 5 additions & 5 deletions broadcast_messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions ci_yml_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
)

// CIYMLTemplatesService handles communication with the gitlab
Expand Down
1 change: 1 addition & 0 deletions commits.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
"net/url"
"time"
)
Expand Down
12 changes: 6 additions & 6 deletions commits_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

Expand Down Expand Up @@ -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}]`)
})

Expand All @@ -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)

Expand Down Expand Up @@ -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")
})

Expand Down Expand Up @@ -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")
})
Expand Down Expand Up @@ -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")
})

Expand Down
1 change: 1 addition & 0 deletions custom_attributes.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
)

// CustomAttributesService handles communication with the group, project and
Expand Down
22 changes: 11 additions & 11 deletions custom_attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]`)
})

Expand All @@ -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"}]`)
})

Expand All @@ -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"}]`)
})

Expand All @@ -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"}`)
})

Expand All @@ -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"}`)
})

Expand All @@ -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"}`)
})

Expand All @@ -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"}`)
})

Expand All @@ -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"}`)
})

Expand All @@ -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)
})

Expand All @@ -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)
})

Expand All @@ -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)
})

Expand Down
1 change: 1 addition & 0 deletions deploy_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package gitlab

import (
"fmt"
"net/http"
"time"
)

Expand Down
Loading

0 comments on commit 03f8b71

Please sign in to comment.