pkg/plugins: use constants for http methods

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2019-10-12 20:44:07 +02:00
parent 5ba167ce8a
commit aa655a4d73
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
4 changed files with 7 additions and 7 deletions

View File

@ -70,7 +70,7 @@ func TestEchoInputOutput(t *testing.T) {
m := Manifest{[]string{"VolumeDriver", "NetworkDriver"}}
mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
if r.Method != http.MethodPost {
t.Fatalf("Expected POST, got %s\n", r.Method)
}
@ -185,7 +185,7 @@ func TestClientStream(t *testing.T) {
var output Manifest
mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
if r.Method != http.MethodPost {
t.Fatalf("Expected POST, got %s", r.Method)
}
@ -218,7 +218,7 @@ func TestClientSendFile(t *testing.T) {
t.Fatal(err)
}
mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
if r.Method != http.MethodPost {
t.Fatalf("Expected POST, got %s\n", r.Method)
}
@ -263,7 +263,7 @@ type testRequestWrapper struct {
}
func (w *testRequestWrapper) NewRequest(path string, data io.Reader) (*http.Request, error) {
req, err := http.NewRequest("POST", path, data)
req, err := http.NewRequest(http.MethodPost, path, data)
if err != nil {
return nil, err
}

View File

@ -95,7 +95,7 @@ func TestPluginWithNoManifest(t *testing.T) {
}
mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
if r.Method != http.MethodPost {
t.Fatalf("Expected POST, got %s\n", r.Method)
}

View File

@ -17,5 +17,5 @@ func TestHTTPTransport(t *testing.T) {
if err != nil {
t.Fatal(err)
}
assert.Check(t, is.Equal("POST", request.Method))
assert.Check(t, is.Equal(http.MethodPost, request.Method))
}

View File

@ -27,7 +27,7 @@ func newHTTPRequest(path string, data io.Reader) (*http.Request, error) {
if !strings.HasPrefix(path, "/") {
path = "/" + path
}
req, err := http.NewRequest("POST", path, data)
req, err := http.NewRequest(http.MethodPost, path, data)
if err != nil {
return nil, err
}